@@ -241,6 +241,7 @@ public function testCookiesAndHeaders()
241241 $ id = uniqid ();
242242 $ cookie1 = new Cookie ('Name ' , 'Hyperf ' );
243243 $ cookie2 = new Cookie ('Request-Id ' , $ id );
244+ $ cookie3 = new Cookie ('Cleared ' , '' );
244245 $ swooleResponse ->shouldReceive ('status ' )->with (200 , 'OK ' )->andReturnUsing (function ($ code ) {
245246 $ this ->assertSame ($ code , 200 );
246247 return true ;
@@ -251,17 +252,17 @@ public function testCookiesAndHeaders()
251252 }
252253 return true ;
253254 });
254- $ swooleResponse ->shouldReceive ('rawcookie ' )->withAnyArgs ()->twice ( )->andReturnUsing (function ($ name , $ value , ...$ args ) use ($ id ) {
255- $ this ->assertTrue ($ name == 'Name ' || $ name == 'Request-Id ' );
256- $ this ->assertTrue ($ value == 'Hyperf ' || $ value == $ id );
255+ $ swooleResponse ->shouldReceive ('rawcookie ' )->withAnyArgs ()->times ( 3 )->andReturnUsing (function ($ name , $ value , ...$ args ) use ($ id ) {
256+ $ this ->assertTrue (in_array ( $ name, [ 'Name ' , 'Request-Id ' , ' Cleared ' ]) );
257+ $ this ->assertTrue (in_array ( $ value, [ 'Hyperf ' , $ id , ' deleted ' ]) );
257258 return true ;
258259 });
259260 $ swooleResponse ->shouldReceive ('end ' )->once ()->andReturn (true );
260261
261262 Context::set (PsrResponseInterface::class, $ psrResponse = new \Hyperf \HttpMessage \Server \Response ());
262263
263264 $ response = new Response ();
264- $ response = $ response ->withCookie ($ cookie1 )->withCookie ($ cookie2 )->withHeader ('X-Token ' , 'xxx ' )->withStatus (200 );
265+ $ response = $ response ->withCookie ($ cookie1 )->withCookie ($ cookie2 )->withCookie ( $ cookie3 )-> withHeader ('X-Token ' , 'xxx ' )->withStatus (200 );
265266
266267 $ this ->assertInstanceOf (Response::class, $ response );
267268 $ this ->assertInstanceOf (ResponseInterface::class, $ response );
0 commit comments