From d88eef8fcab26de2d58ed48922f03b2011e4edb4 Mon Sep 17 00:00:00 2001 From: John Pedrie Date: Mon, 31 May 2021 12:24:07 -0400 Subject: [PATCH] chore: fix unit test failure on windows (#4050) --- .kokoro/presubmit/windows/test.bat | 6 +++++- Core/src/ClientTrait.php | 2 -- Core/tests/Unit/ClientTraitTest.php | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.kokoro/presubmit/windows/test.bat b/.kokoro/presubmit/windows/test.bat index 801c87f16cfb..9736942d5293 100755 --- a/.kokoro/presubmit/windows/test.bat +++ b/.kokoro/presubmit/windows/test.bat @@ -8,7 +8,11 @@ CALL php C:\Users\kbuilder\bin\composer self-update CALL php C:\Users\kbuilder\bin\composer update IF "%SHORT_JOB_NAME%" neq "php70" ( - CALL vendor/bin/phpunit --log-junit %SHORT_JOB_NAME%\unit\sponge_log.xml + IF "%SHORT_JOB_NAME%"=="php56" ( + CALL vendor/bin/phpunit -c phpunit-php5.xml.dist --log-junit %SHORT_JOB_NAME%\unit\sponge_log.xml + ) ELSE ( + CALL vendor/bin/phpunit --log-junit %SHORT_JOB_NAME%\unit\sponge_log.xml + ) ) ELSE ( CALL vendor/bin/phpunit ) diff --git a/Core/src/ClientTrait.php b/Core/src/ClientTrait.php index 176d0c5c6e44..a55c3ab05b35 100644 --- a/Core/src/ClientTrait.php +++ b/Core/src/ClientTrait.php @@ -19,10 +19,8 @@ use Google\Auth\CredentialsLoader; use Google\Auth\Credentials\GCECredentials; -use Google\Auth\HttpHandler\HttpHandlerFactory; use Google\Cloud\Core\Compute\Metadata; use Google\Cloud\Core\Exception\GoogleException; -use GuzzleHttp\Psr7; /** * Provides functionality common to each service client. diff --git a/Core/tests/Unit/ClientTraitTest.php b/Core/tests/Unit/ClientTraitTest.php index 311f47e2817b..8e8008c0f450 100644 --- a/Core/tests/Unit/ClientTraitTest.php +++ b/Core/tests/Unit/ClientTraitTest.php @@ -25,7 +25,7 @@ /** * @group core - * @group client-trait + * @group core-client-trait */ class ClientTraitTest extends TestCase { @@ -342,7 +342,7 @@ public function testDetectProjectIdWithKeyfileMissingProjectId() public function testDetectProjectIdWithKeyfileMissingProjectIdSuppressNotice() { - $trait = TestHelpers::impl(ClientTrait::class); + $trait = TestHelpers::impl(ClientTraitStubOnGceReturnsFalse::class); $res = $trait->call('detectProjectId', [[ 'keyFile' => [], @@ -367,6 +367,16 @@ protected function getMetadata() } } +trait ClientTraitStubOnGceReturnsFalse +{ + use ClientTrait; + + protected function onGce($httpHandler) + { + return false; + } +} + trait ClientTraitStubGrpcDependencyChecks { use ClientTrait;