@@ -21,48 +21,66 @@ accept your pull requests.
2121
2222## Contributing A Patch
2323
24- 1 . Submit an issue describing your proposed change to the repo in question .
24+ 1 . Submit an issue describing your proposed change.
25251 . The repo owner will respond to your issue promptly.
26261 . If your proposed change is accepted, and you haven't already done so, sign a
2727 Contributor License Agreement (see details above).
28- 1 . Fork the desired repo, develop and test your code changes.
29-
30- Install dependencies via [ Composer] ( http://getcomposer.org/doc/00-intro.md ) .
31- Run ` composer install ` (if composer is installed globally).
32-
33- To run the tests, first set up [ application default
34- credentials] ( https://cloud.google.com/docs/authentication/getting-started )
35- by setting the environment variable ` GOOGLE_APPLICATION_CREDENTIALS ` to the
36- path to a service account key JSON file.
37-
38- Then set any environment variables needed by the test. Take a look in
39- ` .kokoro/secrets-example.sh ` for a list of all environment variables used in
40- the tests, and in ` $SAMPLES_DIRECTORY/test ` to see the specific variables used
41- in each test.
42- ```
43- export GOOGLE_PROJECT_ID=YOUR_PROJECT_ID
44- export GOOGLE_STORAGE_BUCKET=YOUR_BUCKET
45- ```
46-
47- To run the tests in a samples directory, first run
48- ` composer install -d testing/ ` to install shared test dependencies. Then run
49- ` composer install ` in any directory containing a ` phpunit.xml.dist ` file.
50- Invoke the ` phpunit ` contained in ` testing/vendor/bin/phpunit ` to run the
51- tests.
52- ```
53- SAMPLES_DIRECTORY=translate
54- composer install -d testing/
55- cd $SAMPLES_DIRECTORY
56- composer install
57- ../testing/vendor/bin/phpunit
58- ```
59-
28+ 1 . Fork this repo, develop and test your code changes.
60291 . Ensure that your code adheres to the existing style in the sample to which
6130 you are contributing.
62311 . Ensure that your code has an appropriate set of unit tests which all pass.
63- Set up [ Travis] ( ./TRAVIS.md ) to run the unit tests on your fork.
64321 . Submit a pull request.
6533
34+ ## Testing your code changes.
35+
36+ ### Install dependencies
37+
38+ To run the tests in a samples directory, you will need to install
39+ [ Composer] ( http://getcomposer.org/doc/00-intro.md ) .
40+
41+ First install the testing dependencies which are shared across all samples:
42+
43+ ```
44+ composer install -d testing/
45+ ```
46+
47+ Next, install the dependencies for the individual sample you're testing:
48+
49+ ```
50+ SAMPLES_DIRECTORY=translate
51+ cd $SAMPLES_DIRECTORY
52+ composer install
53+ ```
54+
55+ ### Environment variables
56+ Set up [ application default credentials] ( https://cloud.google.com/docs/authentication/getting-started )
57+ by setting the environment variable ` GOOGLE_APPLICATION_CREDENTIALS ` to the path to a service
58+ account key JSON file.
59+
60+ Then set any environment variables needed by the test. Check the
61+ ` $SAMPLES_DIRECTORY/test ` directory to see what specific variables are needed.
62+ ```
63+ export GOOGLE_PROJECT_ID=YOUR_PROJECT_ID
64+ export GOOGLE_STORAGE_BUCKET=YOUR_BUCKET
65+ ```
66+
67+ If your tests require new environment variables, you can set them up in
68+ [ .kokoro/secrets.sh.enc] ( .kokoro/secrets.sh.enc ) . For instructions on managing those variables,
69+ view [ .kokoro/secrets-example.sh] ( .kokoro/secrets-example.sh ) for more information.
70+
71+ ### Run the tests
72+
73+ Once the dependencies are installed and the environment variables set, you can run the
74+ tests in a samples directory.
75+ ```
76+ cd $SAMPLES_DIRECTORY
77+ # Execute the "phpunit" installed for the shared dependencies
78+ PATH_TO_REPO=/path/to/php-docs-samples
79+ $PATH_TO_REPO/testing/vendor/bin/phpunit
80+ ```
81+
82+ Use ` phpunit -v ` to get a more detailed output if there are errors.
83+
6684## Style
6785
6886Samples in this repository follow the [ PSR2] [ psr2 ] and [ PSR4] [ psr4 ]
0 commit comments