@@ -70,7 +70,7 @@ public function testLoadsOKIfEnvSpecifiedIsValid()
7070
7171 public function testLoadsDefaultFileIfPresentAndEnvVarIsNotSet ()
7272 {
73- putenv ( ' HOME= ' . __DIR__ . '/fixtures ' );
73+ setHomeEnv ( __DIR__ . '/fixtures ' );
7474 $ this ->assertNotNull (
7575 ApplicationDefaultCredentials::getCredentials ('a scope ' )
7676 );
@@ -80,7 +80,7 @@ public function testFailsIfNotOnGceAndNoDefaultFileFound()
8080 {
8181 $ this ->expectException (DomainException::class);
8282
83- putenv ( ' HOME= ' . __DIR__ . '/not_exist_fixtures ' );
83+ setHomeEnv ( __DIR__ . '/not_exist_fixtures ' );
8484 // simulate not being GCE and retry attempts by returning multiple 500s
8585 $ httpHandler = getHandler ([
8686 new Response (500 ),
@@ -93,7 +93,7 @@ public function testFailsIfNotOnGceAndNoDefaultFileFound()
9393
9494 public function testSuccedsIfNoDefaultFilesButIsOnGCE ()
9595 {
96- putenv ( ' HOME ' );
96+ setHomeEnv ( null );
9797
9898 $ wantedTokens = [
9999 'access_token ' => '1/abdef1234567890 ' ,
@@ -116,7 +116,7 @@ public function testSuccedsIfNoDefaultFilesButIsOnGCE()
116116
117117 public function testGceCredentials ()
118118 {
119- putenv ( ' HOME ' );
119+ setHomeEnv ( null );
120120
121121 $ jsonTokens = json_encode (['access_token ' => 'abc ' ]);
122122
@@ -160,7 +160,7 @@ public function testGceCredentials()
160160
161161 public function testImpersonatedServiceAccountCredentials ()
162162 {
163- putenv ( ' HOME= ' . __DIR__ . '/fixtures5 ' );
163+ setHomeEnv ( __DIR__ . '/fixtures5 ' );
164164 $ creds = ApplicationDefaultCredentials::getCredentials (
165165 null ,
166166 null ,
@@ -183,7 +183,7 @@ public function testImpersonatedServiceAccountCredentials()
183183
184184 public function testUserRefreshCredentials ()
185185 {
186- putenv ( ' HOME= ' . __DIR__ . '/fixtures2 ' );
186+ setHomeEnv ( __DIR__ . '/fixtures2 ' );
187187
188188 $ creds = ApplicationDefaultCredentials::getCredentials (
189189 null , // $scope
@@ -219,7 +219,7 @@ public function testUserRefreshCredentials()
219219
220220 public function testServiceAccountCredentials ()
221221 {
222- putenv ( ' HOME= ' . __DIR__ . '/fixtures ' );
222+ setHomeEnv ( __DIR__ . '/fixtures ' );
223223
224224 $ creds = ApplicationDefaultCredentials::getCredentials (
225225 null , // $scope
@@ -255,7 +255,7 @@ public function testServiceAccountCredentials()
255255
256256 public function testDefaultScopeArray ()
257257 {
258- putenv ( ' HOME= ' . __DIR__ . '/fixtures2 ' );
258+ setHomeEnv ( __DIR__ . '/fixtures2 ' );
259259
260260 $ creds = ApplicationDefaultCredentials::getCredentials (
261261 null , // $scope
@@ -292,15 +292,15 @@ public function testGetMiddlewareLoadsOKIfEnvSpecifiedIsValid()
292292
293293 public function testLGetMiddlewareoadsDefaultFileIfPresentAndEnvVarIsNotSet ()
294294 {
295- putenv ( ' HOME= ' . __DIR__ . '/fixtures ' );
295+ setHomeEnv ( __DIR__ . '/fixtures ' );
296296 $ this ->assertNotNull (ApplicationDefaultCredentials::getMiddleware ('a scope ' ));
297297 }
298298
299299 public function testGetMiddlewareFailsIfNotOnGceAndNoDefaultFileFound ()
300300 {
301301 $ this ->expectException (DomainException::class);
302302
303- putenv ( ' HOME= ' . __DIR__ . '/not_exist_fixtures ' );
303+ setHomeEnv ( __DIR__ . '/not_exist_fixtures ' );
304304
305305 // simulate not being GCE and retry attempts by returning multiple 500s
306306 $ httpHandler = getHandler ([
@@ -356,7 +356,7 @@ public function testOnGceCacheWithHit()
356356 {
357357 $ this ->expectException (DomainException::class);
358358
359- putenv ( ' HOME= ' . __DIR__ . '/not_exist_fixtures ' );
359+ setHomeEnv ( __DIR__ . '/not_exist_fixtures ' );
360360
361361 $ mockCacheItem = $ this ->prophesize ('Psr\Cache\CacheItemInterface ' );
362362 $ mockCacheItem ->isHit ()
@@ -380,7 +380,7 @@ public function testOnGceCacheWithHit()
380380
381381 public function testOnGceCacheWithoutHit ()
382382 {
383- putenv ( ' HOME= ' . __DIR__ . '/not_exist_fixtures ' );
383+ setHomeEnv ( __DIR__ . '/not_exist_fixtures ' );
384384
385385 $ gceIsCalled = false ;
386386 $ dummyHandler = function ($ request ) use (&$ gceIsCalled ) {
@@ -416,7 +416,7 @@ public function testOnGceCacheWithoutHit()
416416
417417 public function testOnGceCacheWithOptions ()
418418 {
419- putenv ( ' HOME= ' . __DIR__ . '/not_exist_fixtures ' );
419+ setHomeEnv ( __DIR__ . '/not_exist_fixtures ' );
420420
421421 $ prefix = 'test_prefix_ ' ;
422422 $ lifetime = '70707 ' ;
@@ -473,7 +473,7 @@ public function testGetIdTokenCredentialsLoadsOKIfEnvSpecifiedIsValid()
473473
474474 public function testGetIdTokenCredentialsLoadsDefaultFileIfPresentAndEnvVarIsNotSet ()
475475 {
476- putenv ( ' HOME= ' . __DIR__ . '/fixtures ' );
476+ setHomeEnv ( __DIR__ . '/fixtures ' );
477477 $ creds = ApplicationDefaultCredentials::getIdTokenCredentials ($ this ->targetAudience );
478478 $ this ->assertInstanceOf (ServiceAccountCredentials::class, $ creds );
479479 }
@@ -483,7 +483,7 @@ public function testGetIdTokenCredentialsFailsIfNotOnGceAndNoDefaultFileFound()
483483 $ this ->expectException (DomainException::class);
484484 $ this ->expectExceptionMessage ('Your default credentials were not found ' );
485485
486- putenv ( ' HOME= ' . __DIR__ . '/not_exist_fixtures ' );
486+ setHomeEnv ( __DIR__ . '/not_exist_fixtures ' );
487487
488488 // simulate not being GCE and retry attempts by returning multiple 500s
489489 $ httpHandler = getHandler ([
@@ -500,7 +500,7 @@ public function testGetIdTokenCredentialsFailsIfNotOnGceAndNoDefaultFileFound()
500500
501501 public function testGetIdTokenCredentialsWithImpersonatedServiceAccountCredentials ()
502502 {
503- putenv ( ' HOME= ' . __DIR__ . '/fixtures5 ' );
503+ setHomeEnv ( __DIR__ . '/fixtures5 ' );
504504 $ creds = ApplicationDefaultCredentials::getIdTokenCredentials ('123@456.com ' );
505505 $ this ->assertInstanceOf (ImpersonatedServiceAccountCredentials::class, $ creds );
506506 }
@@ -529,7 +529,7 @@ public function testGetIdTokenCredentialsWithCacheOptions()
529529
530530 public function testGetIdTokenCredentialsSuccedsIfNoDefaultFilesButIsOnGCE ()
531531 {
532- putenv ( ' HOME= ' . __DIR__ . '/not_exist_fixtures ' );
532+ setHomeEnv ( __DIR__ . '/not_exist_fixtures ' );
533533 $ wantedTokens = [
534534 'access_token ' => '1/abdef1234567890 ' ,
535535 'expires_in ' => '57 ' ,
@@ -553,7 +553,7 @@ public function testGetIdTokenCredentialsSuccedsIfNoDefaultFilesButIsOnGCE()
553553
554554 public function testGetIdTokenCredentialsWithUserRefreshCredentials ()
555555 {
556- putenv ( ' HOME= ' . __DIR__ . '/fixtures2 ' );
556+ setHomeEnv ( __DIR__ . '/fixtures2 ' );
557557
558558 $ creds = ApplicationDefaultCredentials::getIdTokenCredentials (
559559 $ this ->targetAudience ,
@@ -610,7 +610,7 @@ public function testGetCredentialsUtilizesQuotaProjectEnvVar()
610610 {
611611 $ quotaProject = 'quota-project-from-env-var ' ;
612612 putenv (CredentialsLoader::QUOTA_PROJECT_ENV_VAR . '= ' . $ quotaProject );
613- putenv ( ' HOME= ' . __DIR__ . '/fixtures ' );
613+ setHomeEnv ( __DIR__ . '/fixtures ' );
614614
615615 $ credentials = ApplicationDefaultCredentials::getCredentials ();
616616
@@ -625,7 +625,7 @@ public function testGetCredentialsUtilizesQuotaProjectParameterOverEnvVar()
625625 {
626626 $ quotaProject = 'quota-project-from-parameter ' ;
627627 putenv (CredentialsLoader::QUOTA_PROJECT_ENV_VAR . '=quota-project-from-env-var ' );
628- putenv ( ' HOME= ' . __DIR__ . '/fixtures ' );
628+ setHomeEnv ( __DIR__ . '/fixtures ' );
629629
630630 $ credentials = ApplicationDefaultCredentials::getCredentials (
631631 null , // $scope
@@ -688,7 +688,7 @@ public function testWithFetchAuthTokenCacheAndExplicitQuotaProject()
688688
689689 public function testWithGCECredentials ()
690690 {
691- putenv ( ' HOME= ' . __DIR__ . '/not_exist_fixtures ' );
691+ setHomeEnv ( __DIR__ . '/not_exist_fixtures ' );
692692 $ wantedTokens = [
693693 'access_token ' => '1/abdef1234567890 ' ,
694694 'expires_in ' => '57 ' ,
@@ -721,7 +721,7 @@ public function testWithGCECredentials()
721721 public function testAppEngineStandard ()
722722 {
723723 $ _SERVER ['SERVER_SOFTWARE ' ] = 'Google App Engine ' ;
724- putenv ( ' HOME= ' . __DIR__ . '/not_exist_fixtures ' );
724+ setHomeEnv ( __DIR__ . '/not_exist_fixtures ' );
725725 $ this ->assertInstanceOf (
726726 'Google\Auth\Credentials\AppIdentityCredentials ' ,
727727 ApplicationDefaultCredentials::getCredentials ()
@@ -732,7 +732,7 @@ public function testAppEngineFlexible()
732732 {
733733 $ _SERVER ['SERVER_SOFTWARE ' ] = 'Google App Engine ' ;
734734 putenv ('GAE_INSTANCE=aef-default-20180313t154438 ' );
735- putenv ( ' HOME= ' . __DIR__ . '/not_exist_fixtures ' );
735+ setHomeEnv ( __DIR__ . '/not_exist_fixtures ' );
736736 $ httpHandler = getHandler ([
737737 new Response (200 , [GCECredentials::FLAVOR_HEADER => 'Google ' ]),
738738 ]);
@@ -746,7 +746,7 @@ public function testAppEngineFlexibleIdToken()
746746 {
747747 $ _SERVER ['SERVER_SOFTWARE ' ] = 'Google App Engine ' ;
748748 putenv ('GAE_INSTANCE=aef-default-20180313t154438 ' );
749- putenv ( ' HOME= ' . __DIR__ . '/not_exist_fixtures ' );
749+ setHomeEnv ( __DIR__ . '/not_exist_fixtures ' );
750750 $ httpHandler = getHandler ([
751751 new Response (200 , [GCECredentials::FLAVOR_HEADER => 'Google ' ]),
752752 ]);
@@ -868,7 +868,7 @@ public function testUniverseDomainInKeyFile()
868868 /** @runInSeparateProcess */
869869 public function testUniverseDomainInGceCredentials ()
870870 {
871- putenv ( ' HOME ' );
871+ setHomeEnv ( null );
872872
873873 $ expectedUniverseDomain = 'example-universe.com ' ;
874874 $ creds = ApplicationDefaultCredentials::getCredentials (
0 commit comments