@@ -42,19 +42,8 @@ Write samples according to the [sample style guide](https://googlecloudplatform.
42
42
To run the tests in a samples directory, you will need to install
43
43
[ Composer] ( http://getcomposer.org/doc/00-intro.md ) .
44
44
45
- First install the testing dependencies which are shared across all samples:
46
-
47
- ```
48
- composer install -d testing/
49
- ```
50
-
51
- Next, install the dependencies for the individual sample you're testing:
52
-
53
- ```
54
- SAMPLES_DIRECTORY=translate
55
- cd $SAMPLES_DIRECTORY
56
- composer install
57
- ```
45
+ First install dependencies as described in the
46
+ [ README.md] ( google-analytics-data/README.md ) .
58
47
59
48
### Environment variables
60
49
Some tests require specific environment variables to run. PHPUnit will skip the tests
@@ -64,27 +53,17 @@ to run against any sample project as follows:
64
53
65
54
```
66
55
export GOOGLE_PROJECT_ID=YOUR_PROJECT_ID
67
- export GOOGLE_STORAGE_BUCKET=YOUR_BUCKET
56
+ export GA_TEST_PROPERTY_ID=YOUR_GA4_PROPERTY_ID
68
57
```
69
58
70
- If you have access to the Google Cloud Kokoro project, decrypt the
71
- ` .kokoro/secrets.sh.enc ` file and load those environment variables. Follow
72
- the instructions in [ .kokoro/secrets-example.sh] ( .kokoro/secrets-example.sh ) .
73
-
74
- If your tests require new environment variables, you can set them up in
75
- ` .kokoro/secrets.sh.enc ` so they pass on Kokoro. For instructions on managing those
76
- variables, view [ .kokoro/secrets-example.sh] ( .kokoro/secrets-example.sh ) for more
77
- information.
78
-
79
59
### Run the tests
80
60
81
61
Once the dependencies are installed and the environment variables set, you can run the
82
62
tests in a samples directory.
83
63
```
84
- cd $SAMPLES_DIRECTORY
64
+ cd google-analytics-data
85
65
# Execute the "phpunit" installed for the shared dependencies
86
- PATH_TO_REPO=/path/to/php-docs-samples
87
- $PATH_TO_REPO/testing/vendor/bin/phpunit
66
+ ./vendor/bin/phpunit
88
67
```
89
68
90
69
Use ` phpunit -v ` to get a more detailed output if there are errors.
@@ -102,18 +81,16 @@ recommendations. This is enforced using [PHP CS Fixer][php-cs-fixer], using the
102
81
Install that by running
103
82
104
83
```
105
- composer global require friendsofphp/php-cs-fixer
84
+ RUN composer require --dev friendsofphp/php-cs-fixer
106
85
```
107
86
108
87
Then to fix your directory or file run
109
88
110
89
```
111
- php-cs-fixer fix . --config .php-cs-fixer.dist.php
112
- php-cs-fixer fix path/to/file --config .php-cs-fixer.dist.php
90
+ ./vendor/bin/ php-cs-fixer fix --config .php-cs-fixer.dist.php .
91
+ ./vendor/bin/ php-cs-fixer fix --config .php-cs-fixer.dist.php path/to/file
113
92
```
114
93
115
- The [ DLP snippets] ( https://github.com/GoogleCloudPlatform/php-docs-samples/tree/main/dlp ) are an example of snippets following the latest style guidelines.
116
-
117
94
[ psr2 ] : http://www.php-fig.org/psr/psr-2/
118
95
[ psr4 ] : http://www.php-fig.org/psr/psr-4/
119
96
[ php-cs-fixer ] : https://github.com/FriendsOfPHP/PHP-CS-Fixer
0 commit comments