@@ -83,7 +83,6 @@ public function buildDataWithoutExplicitKeyFile()
8383 $ appDefaultCreds = getenv ('GOOGLE_APPLICATION_CREDENTIALS ' );
8484 putenv ('GOOGLE_APPLICATION_CREDENTIALS= ' . __DIR__ . '/testdata/json-key-file.json ' );
8585 $ scopes = ['myscope ' ];
86- $ defaultAuthHttpHandler = HttpHandlerFactory::build ();
8786 $ authHttpHandler = HttpHandlerFactory::build ();
8887 $ asyncAuthHttpHandler = function ($ request , $ options ) use ($ authHttpHandler ) {
8988 return $ authHttpHandler ->async ($ request , $ options )->wait ();
@@ -96,31 +95,31 @@ public function buildDataWithoutExplicitKeyFile()
9695 $ testData = [
9796 [
9897 [],
99- new CredentialsWrapper (ApplicationDefaultCredentials::getCredentials (null , $ defaultAuthHttpHandler , null , $ defaultAuthCache ), $ defaultAuthHttpHandler ),
98+ new CredentialsWrapper (ApplicationDefaultCredentials::getCredentials (null , $ authHttpHandler , null , $ defaultAuthCache )),
10099 ],
101100 [
102101 ['scopes ' => $ scopes ],
103- new CredentialsWrapper (ApplicationDefaultCredentials::getCredentials ($ scopes , $ defaultAuthHttpHandler , null , $ defaultAuthCache ), $ defaultAuthHttpHandler ),
102+ new CredentialsWrapper (ApplicationDefaultCredentials::getCredentials ($ scopes , $ authHttpHandler , null , $ defaultAuthCache )),
104103 ],
105104 [
106105 ['scopes ' => $ scopes , 'authHttpHandler ' => $ asyncAuthHttpHandler ],
107106 new CredentialsWrapper (ApplicationDefaultCredentials::getCredentials ($ scopes , $ asyncAuthHttpHandler , null , $ defaultAuthCache ), $ asyncAuthHttpHandler ),
108107 ],
109108 [
110109 ['enableCaching ' => false ],
111- new CredentialsWrapper (ApplicationDefaultCredentials::getCredentials (null , $ defaultAuthHttpHandler , null , null ), $ defaultAuthHttpHandler ),
110+ new CredentialsWrapper (ApplicationDefaultCredentials::getCredentials (null , $ authHttpHandler , null , null )),
112111 ],
113112 [
114113 ['authCacheOptions ' => $ authCacheOptions ],
115- new CredentialsWrapper (ApplicationDefaultCredentials::getCredentials (null , $ defaultAuthHttpHandler , $ authCacheOptions , $ defaultAuthCache ), $ defaultAuthHttpHandler ),
114+ new CredentialsWrapper (ApplicationDefaultCredentials::getCredentials (null , $ authHttpHandler , $ authCacheOptions , $ defaultAuthCache )),
116115 ],
117116 [
118117 ['authCache ' => $ authCache ],
119- new CredentialsWrapper (ApplicationDefaultCredentials::getCredentials (null , $ defaultAuthHttpHandler , null , $ authCache ), $ defaultAuthHttpHandler ),
118+ new CredentialsWrapper (ApplicationDefaultCredentials::getCredentials (null , $ authHttpHandler , null , $ authCache )),
120119 ],
121120 [
122121 ['quotaProject ' => $ quotaProject ],
123- new CredentialsWrapper (ApplicationDefaultCredentials::getCredentials (null , $ defaultAuthHttpHandler , null , $ defaultAuthCache , $ quotaProject ), $ defaultAuthHttpHandler ),
122+ new CredentialsWrapper (ApplicationDefaultCredentials::getCredentials (null , $ authHttpHandler , null , $ defaultAuthCache , $ quotaProject )),
124123 ],
125124 ];
126125
@@ -557,4 +556,13 @@ public function testGetProjectIdWithFetchAuthTokenCache()
557556 $ credentialsWrapper = new CredentialsWrapper ($ cache );
558557 $ this ->assertEquals ('my-project-id ' , $ credentialsWrapper ->getProjectId ());
559558 }
559+
560+ public function testSerializeCredentialsWrapper ()
561+ {
562+ $ credentialsWrapper = CredentialsWrapper::build ([
563+ 'keyFile ' => __DIR__ . '/testdata/json-key-file.json ' ,
564+ ]);
565+ $ serialized = serialize ($ credentialsWrapper );
566+ $ this ->assertIsString ($ serialized );
567+ }
560568}
0 commit comments