From ec7316aaaa2662001bd2dbcb9b451cc69dce4c77 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 20 Apr 2022 11:20:11 -0600 Subject: [PATCH 01/10] chore: add kokoro configs for running tests on PHP 7.4 and 8.0 --- .kokoro/presubmit/php74.cfg | 7 +++++++ .kokoro/presubmit/php80.cfg | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 .kokoro/presubmit/php74.cfg create mode 100644 .kokoro/presubmit/php80.cfg diff --git a/.kokoro/presubmit/php74.cfg b/.kokoro/presubmit/php74.cfg new file mode 100644 index 000000000000..17cf1918a27f --- /dev/null +++ b/.kokoro/presubmit/php74.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/php74" +} diff --git a/.kokoro/presubmit/php80.cfg b/.kokoro/presubmit/php80.cfg new file mode 100644 index 000000000000..cb0edc2c4e7c --- /dev/null +++ b/.kokoro/presubmit/php80.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/php80" +} From 4d90f0989952744d95dc39073d9418afd8d9781a Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 20 Apr 2022 11:21:27 -0600 Subject: [PATCH 02/10] update PHP version for docs --- .kokoro/presubmit/run-tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.kokoro/presubmit/run-tests.sh b/.kokoro/presubmit/run-tests.sh index 41ded3340b40..063edffd51bc 100755 --- a/.kokoro/presubmit/run-tests.sh +++ b/.kokoro/presubmit/run-tests.sh @@ -45,8 +45,8 @@ echo "Running Snippet Test Suite" vendor/bin/phpunit -c phpunit${PHPUNIT_SUFFIX}.xml.dist --verbose --log-junit \ ${SNIPPETS_LOG_FILENAME} -# Run docs gen on PHP 7.3 only -if [ "7.3" == ${PHP_VERSION:0:3} ]; then +# Run docs gen on PHP 8.0 only +if [ "8.0" == ${PHP_VERSION:0:3} ]; then echo "Running Doc Generator" # Require phpdocumentor:4 for docs generation From c96128105a2ea92e1d7a6665d804054c17c0a126 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 20 Apr 2022 11:26:46 -0600 Subject: [PATCH 03/10] use php80 for continuous tests --- .kokoro/continuous/{php72.cfg => php80.cfg} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .kokoro/continuous/{php72.cfg => php80.cfg} (96%) diff --git a/.kokoro/continuous/php72.cfg b/.kokoro/continuous/php80.cfg similarity index 96% rename from .kokoro/continuous/php72.cfg rename to .kokoro/continuous/php80.cfg index b847cc0d5772..8a67d2c476f0 100644 --- a/.kokoro/continuous/php72.cfg +++ b/.kokoro/continuous/php80.cfg @@ -15,7 +15,7 @@ env_vars: { # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/php72" + value: "gcr.io/cloud-devrel-kokoro-resources/php80" } # key files from keystore From 5a6118e770974208bf8bdac98cbf1c4dabb7c186 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 20 Apr 2022 11:39:49 -0600 Subject: [PATCH 04/10] update kokoro to ues php 8 for docs gen --- .github/workflows/docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index abbd9f1249c4..5162cea7e602 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -8,7 +8,7 @@ on: jobs: docs: - name: "Generate Project Documentation" + name: "Generate Project Do ghcumentation" runs-on: ubuntu-latest steps: - id: getTag @@ -21,7 +21,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '7.3' + php-version: '8.0' ini-values: memory_limit=2048M - name: Install Dependencies uses: nick-invision/retry@v1 From dd302e22397b53493b2b93bdf6d952816194c7d2 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 20 Apr 2022 13:37:22 -0600 Subject: [PATCH 05/10] update cs library and fix cs --- Core/src/Batch/BatchTrait.php | 2 +- Spanner/tests/Snippet/Batch/PartitionSharedSnippetTestTrait.php | 2 +- composer.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/src/Batch/BatchTrait.php b/Core/src/Batch/BatchTrait.php index 21f49a2c4fb6..a8a02e98380d 100644 --- a/Core/src/Batch/BatchTrait.php +++ b/Core/src/Batch/BatchTrait.php @@ -130,7 +130,7 @@ public function send(array $items) * * @return array */ - protected abstract function getCallback(); + abstract protected function getCallback(); /** * @param array $options [optional] { diff --git a/Spanner/tests/Snippet/Batch/PartitionSharedSnippetTestTrait.php b/Spanner/tests/Snippet/Batch/PartitionSharedSnippetTestTrait.php index bddfd783e140..78e53d5cb95c 100644 --- a/Spanner/tests/Snippet/Batch/PartitionSharedSnippetTestTrait.php +++ b/Spanner/tests/Snippet/Batch/PartitionSharedSnippetTestTrait.php @@ -26,7 +26,7 @@ trait PartitionSharedSnippetTestTrait private $token = 'token'; private $options = ['hello' => 'world']; - public abstract function setUp(); + abstract public function setUp(); /** * @dataProvider provideSerializeSnippetIndex diff --git a/composer.json b/composer.json index 17ef847ce8a9..ee58f39fff4c 100644 --- a/composer.json +++ b/composer.json @@ -57,7 +57,7 @@ }, "require-dev": { "phpunit/phpunit": "^4.8|^5.0", - "squizlabs/php_codesniffer": "2.*", + "squizlabs/php_codesniffer": "3.*", "phpdocumentor/reflection": "^3.0", "symfony/console": "^3.0", "erusev/parsedown": "^1.6", From 60fe1387b5e1d22159f1cee001d4e1078dd3b448 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 20 Apr 2022 13:45:00 -0600 Subject: [PATCH 06/10] hopefully fix tests --- BigQuery/tests/Unit/QueryResultsTest.php | 1 + .../tests/Unit/FirestoreSessionHandlerTest.php | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/BigQuery/tests/Unit/QueryResultsTest.php b/BigQuery/tests/Unit/QueryResultsTest.php index a81db69aa84c..036f58ff0cb1 100644 --- a/BigQuery/tests/Unit/QueryResultsTest.php +++ b/BigQuery/tests/Unit/QueryResultsTest.php @@ -36,6 +36,7 @@ class QueryResultsTest extends TestCase public $jobId = 'myJobId'; public $queryData = [ 'jobComplete' => true, + 'jobReference' => ['location' => null], 'rows' => [ ['f' => [['v' => 'Alton'], ['v' => 1]]] ], diff --git a/Firestore/tests/Unit/FirestoreSessionHandlerTest.php b/Firestore/tests/Unit/FirestoreSessionHandlerTest.php index 0b5b7c4ae33f..c753c6b619ff 100644 --- a/Firestore/tests/Unit/FirestoreSessionHandlerTest.php +++ b/Firestore/tests/Unit/FirestoreSessionHandlerTest.php @@ -56,7 +56,8 @@ public function setUp() public function testOpen() { $this->connection->beginTransaction(['database' => $this->dbName()]) - ->shouldBeCalledTimes(1); + ->shouldBeCalledTimes(1) + ->willReturn(['transaction' => 123]);; $firestoreSessionHandler = new FirestoreSessionHandler( $this->connection->reveal(), $this->valueMapper->reveal(), @@ -90,6 +91,9 @@ public function testOpenWithException() */ public function testReadNotAllowed() { + $this->connection->beginTransaction(['database' => $this->dbName()]) + ->shouldBeCalledTimes(1) + ->willThrow(new ServiceException('')); $firestoreSessionHandler = new FirestoreSessionHandler( $this->connection->reveal(), $this->valueMapper->reveal(), @@ -124,7 +128,8 @@ public function testReadNothing() ->shouldBeCalledTimes(1) ->willReturn(null); $this->connection->beginTransaction(['database' => $this->dbName()]) - ->shouldBeCalledTimes(1); + ->shouldBeCalledTimes(1) + ->willReturn(['transaction' => 123]); $this->connection->batchGetDocuments([ 'database' => $this->dbName(), 'documents' => [$this->documentName()], @@ -150,7 +155,8 @@ public function testReadNothing() public function testReadWithException() { $this->connection->beginTransaction(['database' => $this->dbName()]) - ->shouldBeCalledTimes(1); + ->shouldBeCalledTimes(1) + ->willReturn(['transaction' => 123]); $this->connection->batchGetDocuments([ 'database' => $this->dbName(), 'documents' => [$this->documentName()], @@ -217,7 +223,8 @@ public function testWrite() return ['data' => ['stringValue' => 'sessiondata']]; }); $this->connection->beginTransaction(['database' => $this->dbName()]) - ->shouldBeCalledTimes(1); + ->shouldBeCalledTimes(1) + ->willReturn(['transaction' => 123]); $this->connection->commit([ 'database' => $this->dbName(), 'writes' => [ From df6bb2e22bda4806ca6c5819c0401ca65cc1c548 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 20 Apr 2022 14:40:21 -0600 Subject: [PATCH 07/10] Revert "hopefully fix tests" This reverts commit 60fe1387b5e1d22159f1cee001d4e1078dd3b448. --- BigQuery/tests/Unit/QueryResultsTest.php | 1 - .../tests/Unit/FirestoreSessionHandlerTest.php | 15 ++++----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/BigQuery/tests/Unit/QueryResultsTest.php b/BigQuery/tests/Unit/QueryResultsTest.php index 036f58ff0cb1..a81db69aa84c 100644 --- a/BigQuery/tests/Unit/QueryResultsTest.php +++ b/BigQuery/tests/Unit/QueryResultsTest.php @@ -36,7 +36,6 @@ class QueryResultsTest extends TestCase public $jobId = 'myJobId'; public $queryData = [ 'jobComplete' => true, - 'jobReference' => ['location' => null], 'rows' => [ ['f' => [['v' => 'Alton'], ['v' => 1]]] ], diff --git a/Firestore/tests/Unit/FirestoreSessionHandlerTest.php b/Firestore/tests/Unit/FirestoreSessionHandlerTest.php index c753c6b619ff..0b5b7c4ae33f 100644 --- a/Firestore/tests/Unit/FirestoreSessionHandlerTest.php +++ b/Firestore/tests/Unit/FirestoreSessionHandlerTest.php @@ -56,8 +56,7 @@ public function setUp() public function testOpen() { $this->connection->beginTransaction(['database' => $this->dbName()]) - ->shouldBeCalledTimes(1) - ->willReturn(['transaction' => 123]);; + ->shouldBeCalledTimes(1); $firestoreSessionHandler = new FirestoreSessionHandler( $this->connection->reveal(), $this->valueMapper->reveal(), @@ -91,9 +90,6 @@ public function testOpenWithException() */ public function testReadNotAllowed() { - $this->connection->beginTransaction(['database' => $this->dbName()]) - ->shouldBeCalledTimes(1) - ->willThrow(new ServiceException('')); $firestoreSessionHandler = new FirestoreSessionHandler( $this->connection->reveal(), $this->valueMapper->reveal(), @@ -128,8 +124,7 @@ public function testReadNothing() ->shouldBeCalledTimes(1) ->willReturn(null); $this->connection->beginTransaction(['database' => $this->dbName()]) - ->shouldBeCalledTimes(1) - ->willReturn(['transaction' => 123]); + ->shouldBeCalledTimes(1); $this->connection->batchGetDocuments([ 'database' => $this->dbName(), 'documents' => [$this->documentName()], @@ -155,8 +150,7 @@ public function testReadNothing() public function testReadWithException() { $this->connection->beginTransaction(['database' => $this->dbName()]) - ->shouldBeCalledTimes(1) - ->willReturn(['transaction' => 123]); + ->shouldBeCalledTimes(1); $this->connection->batchGetDocuments([ 'database' => $this->dbName(), 'documents' => [$this->documentName()], @@ -223,8 +217,7 @@ public function testWrite() return ['data' => ['stringValue' => 'sessiondata']]; }); $this->connection->beginTransaction(['database' => $this->dbName()]) - ->shouldBeCalledTimes(1) - ->willReturn(['transaction' => 123]); + ->shouldBeCalledTimes(1); $this->connection->commit([ 'database' => $this->dbName(), 'writes' => [ From 4d67e19e4d55f7000880ef5c5838dfd0362e81f2 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 20 Apr 2022 14:42:26 -0600 Subject: [PATCH 08/10] fix tests for PHP 7.4 --- BigQuery/tests/Unit/QueryResultsTest.php | 3 ++- .../tests/Unit/FirestoreSessionHandlerTest.php | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/BigQuery/tests/Unit/QueryResultsTest.php b/BigQuery/tests/Unit/QueryResultsTest.php index a81db69aa84c..329acca4624b 100644 --- a/BigQuery/tests/Unit/QueryResultsTest.php +++ b/BigQuery/tests/Unit/QueryResultsTest.php @@ -36,6 +36,7 @@ class QueryResultsTest extends TestCase public $jobId = 'myJobId'; public $queryData = [ 'jobComplete' => true, + 'jobReference' => ['location' => 123], 'rows' => [ ['f' => [['v' => 'Alton'], ['v' => 1]]] ], @@ -203,7 +204,7 @@ public function testReloadsInfo() public function testGetsIdentity() { - $queryResults = $this->getQueryResults($this->connection); + $queryResults = $this->getQueryResults($this->connection, $this->queryData); $this->assertEquals($this->jobId, $queryResults->identity()['jobId']); $this->assertEquals($this->projectId, $queryResults->identity()['projectId']); diff --git a/Firestore/tests/Unit/FirestoreSessionHandlerTest.php b/Firestore/tests/Unit/FirestoreSessionHandlerTest.php index 0b5b7c4ae33f..2f169bebf015 100644 --- a/Firestore/tests/Unit/FirestoreSessionHandlerTest.php +++ b/Firestore/tests/Unit/FirestoreSessionHandlerTest.php @@ -56,7 +56,8 @@ public function setUp() public function testOpen() { $this->connection->beginTransaction(['database' => $this->dbName()]) - ->shouldBeCalledTimes(1); + ->shouldBeCalledTimes(1) + ->willReturn(['transaction' => null]); $firestoreSessionHandler = new FirestoreSessionHandler( $this->connection->reveal(), $this->valueMapper->reveal(), @@ -90,6 +91,9 @@ public function testOpenWithException() */ public function testReadNotAllowed() { + $this->connection->beginTransaction(['database' => $this->dbName()]) + ->shouldBeCalledTimes(1) + ->willReturn(['transaction' => null]); $firestoreSessionHandler = new FirestoreSessionHandler( $this->connection->reveal(), $this->valueMapper->reveal(), @@ -124,7 +128,8 @@ public function testReadNothing() ->shouldBeCalledTimes(1) ->willReturn(null); $this->connection->beginTransaction(['database' => $this->dbName()]) - ->shouldBeCalledTimes(1); + ->shouldBeCalledTimes(1) + ->willReturn(['transaction' => null]); $this->connection->batchGetDocuments([ 'database' => $this->dbName(), 'documents' => [$this->documentName()], @@ -150,7 +155,8 @@ public function testReadNothing() public function testReadWithException() { $this->connection->beginTransaction(['database' => $this->dbName()]) - ->shouldBeCalledTimes(1); + ->shouldBeCalledTimes(1) + ->willReturn(['transaction' => null]); $this->connection->batchGetDocuments([ 'database' => $this->dbName(), 'documents' => [$this->documentName()], @@ -186,7 +192,8 @@ public function testReadEntity() ->shouldBeCalledTimes(1) ->willReturn(['data' => 'sessiondata']); $this->connection->beginTransaction(['database' => $this->dbName()]) - ->shouldBeCalledTimes(1); + ->shouldBeCalledTimes(1) + ->willReturn(['transaction' => null]); $this->connection->batchGetDocuments([ 'database' => $this->dbName(), 'documents' => [$this->documentName()], @@ -217,7 +224,8 @@ public function testWrite() return ['data' => ['stringValue' => 'sessiondata']]; }); $this->connection->beginTransaction(['database' => $this->dbName()]) - ->shouldBeCalledTimes(1); + ->shouldBeCalledTimes(1) + ->willReturn(['transaction' => null]); $this->connection->commit([ 'database' => $this->dbName(), 'writes' => [ From 5b0d2d7dd93681bbde7688c225cb2f965c1ce4eb Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 20 Apr 2022 13:56:50 -0700 Subject: [PATCH 09/10] Update docs.yml --- .github/workflows/docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 5162cea7e602..054eaefda81e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -8,7 +8,7 @@ on: jobs: docs: - name: "Generate Project Do ghcumentation" + name: "Generate Project Documentation" runs-on: ubuntu-latest steps: - id: getTag @@ -21,7 +21,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: '7.4' ini-values: memory_limit=2048M - name: Install Dependencies uses: nick-invision/retry@v1 From 20ca00e18b1f13d1011d20f4f7924ea8986e41c8 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 20 Apr 2022 14:57:22 -0600 Subject: [PATCH 10/10] remove 8.0 --- .kokoro/continuous/{php80.cfg => php74.cfg} | 2 +- .kokoro/presubmit/php80.cfg | 7 ------- .kokoro/presubmit/run-tests.sh | 4 ++-- 3 files changed, 3 insertions(+), 10 deletions(-) rename .kokoro/continuous/{php80.cfg => php74.cfg} (96%) delete mode 100644 .kokoro/presubmit/php80.cfg diff --git a/.kokoro/continuous/php80.cfg b/.kokoro/continuous/php74.cfg similarity index 96% rename from .kokoro/continuous/php80.cfg rename to .kokoro/continuous/php74.cfg index 8a67d2c476f0..7b1b7fea8d93 100644 --- a/.kokoro/continuous/php80.cfg +++ b/.kokoro/continuous/php74.cfg @@ -15,7 +15,7 @@ env_vars: { # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/php80" + value: "gcr.io/cloud-devrel-kokoro-resources/php74" } # key files from keystore diff --git a/.kokoro/presubmit/php80.cfg b/.kokoro/presubmit/php80.cfg deleted file mode 100644 index cb0edc2c4e7c..000000000000 --- a/.kokoro/presubmit/php80.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/php80" -} diff --git a/.kokoro/presubmit/run-tests.sh b/.kokoro/presubmit/run-tests.sh index 063edffd51bc..beea3bd6c75a 100755 --- a/.kokoro/presubmit/run-tests.sh +++ b/.kokoro/presubmit/run-tests.sh @@ -45,8 +45,8 @@ echo "Running Snippet Test Suite" vendor/bin/phpunit -c phpunit${PHPUNIT_SUFFIX}.xml.dist --verbose --log-junit \ ${SNIPPETS_LOG_FILENAME} -# Run docs gen on PHP 8.0 only -if [ "8.0" == ${PHP_VERSION:0:3} ]; then +# Run docs gen on PHP 7.4 only +if [ "7.4" == ${PHP_VERSION:0:3} ]; then echo "Running Doc Generator" # Require phpdocumentor:4 for docs generation