@@ -70,6 +70,7 @@ public function testGenerateHttpClient_userProvidedStack()
7070 );
7171 $ stack ->before ('http_errors ' , Middleware::tap ());
7272 $ client = new Client (['handler ' => $ stack ]);
73+ $ originalStack = clone $ stack ;
7374
7475 $ httpClientFactory = new AdsGuzzleHttpClientFactory (
7576 $ logger ,
@@ -80,7 +81,12 @@ public function testGenerateHttpClient_userProvidedStack()
8081
8182 $ this ->assertNotNull ($ httpClient );
8283 $ this ->assertInstanceOf (Client::class, $ httpClient );
83- $ this ->assertEquals ($ stack , $ httpClient ->getConfig ()['handler ' ]);
84+ $ this ->assertEquals ($ originalStack , $ stack , 'Stack of original HTTP client should stay unchanged ' );
85+ $ this ->assertNotEquals (
86+ $ stack ,
87+ $ httpClient ->getConfig ()['handler ' ],
88+ 'Stack of factory created HTTP client should have logging middleware, thus differ from original '
89+ );
8490 }
8591
8692 /**
@@ -97,10 +103,11 @@ public function testGenerateHttpClient_userProvidedConfigs()
97103 GuzzleLogMessageHandler::log ($ logger , $ guzzleLogMessageFormatter )
98104 );
99105 $ client = new Client ([
100- 'handler ' => $ stack ,
101- 'verify ' => true ,
102- 'cookies ' => false
106+ 'handler ' => $ stack ,
107+ 'verify ' => true ,
108+ 'cookies ' => false
103109 ]);
110+ $ originalStack = clone $ stack ;
104111
105112 $ httpClientFactory = new AdsGuzzleHttpClientFactory (
106113 $ logger ,
@@ -111,7 +118,12 @@ public function testGenerateHttpClient_userProvidedConfigs()
111118
112119 $ this ->assertNotNull ($ httpClient );
113120 $ this ->assertInstanceOf (Client::class, $ httpClient );
114- $ this ->assertEquals ($ stack , $ httpClient ->getConfig ()['handler ' ]);
121+ $ this ->assertEquals ($ originalStack , $ stack , 'Stack of original HTTP client should stay unchanged ' );
122+ $ this ->assertNotEquals (
123+ $ stack ,
124+ $ httpClient ->getConfig ()['handler ' ],
125+ 'Stack of factory created HTTP Client should have logging middleware, thus differ from original '
126+ );
115127 $ this ->assertTrue ($ httpClient ->getConfig ()['verify ' ]);
116128 $ this ->assertFalse ($ httpClient ->getConfig ()['cookies ' ]);
117129 }
0 commit comments