@@ -73,15 +73,20 @@ public function testThatSymfonyResponseIsReflected(): void
7373
7474 $ response = $ this ->createMock (Response::class);
7575 $ expectedHeaders = [
76- 1 => ['x-test ' , 'Swoole-Runtime ' ],
77- 2 => ['set-cookie ' , $ fooCookie ],
78- 3 => ['set-cookie ' , $ barCookie ],
76+ ['x-test ' , 'Swoole-Runtime ' ],
77+ ['set-cookie ' , $ fooCookie ],
78+ ['set-cookie ' , $ barCookie ],
7979 ];
80- $ response ->expects (self ::exactly (3 ))->method ('header ' )->willReturnCallback (function ($ key , $ value ) use ($ expectedHeaders ) {
81- $ this ->assertEquals ([$ key , $ value ], array_shift ($ expectedHeaders ));
82-
83- return true ;
84- });
80+ $ callCount = 0 ;
81+ $ response ->expects (self ::exactly (3 ))->method ('header ' )
82+ ->willReturnCallback (function ($ key , $ value ) use ($ expectedHeaders , &$ callCount ) {
83+ $ this ->assertArrayHasKey ($ callCount , $ expectedHeaders );
84+ $ this ->assertEquals ($ expectedHeaders [$ callCount ][0 ], $ key );
85+ $ this ->assertEquals ($ expectedHeaders [$ callCount ][1 ], $ value );
86+ ++$ callCount ;
87+
88+ return true ;
89+ });
8590 $ response ->expects (self ::once ())->method ('status ' )->with (201 );
8691 $ response ->expects (self ::once ())->method ('end ' )->with ('Test ' );
8792
@@ -100,15 +105,18 @@ public function testThatSymfonyStreamedResponseIsReflected(): void
100105
101106 $ response = $ this ->createMock (Response::class);
102107 $ expectedWrites = [
103- 1 => "Foo \n" ,
104- 2 => "Bar \n" ,
105- 3 => '' ,
108+ "Foo \n" ,
109+ "Bar \n" ,
110+ '' ,
106111 ];
107- $ response ->expects (self ::exactly (3 ))->method ('write ' )->willReturnCallback (function ($ string ) use ($ expectedWrites ) {
108- $ this ->assertSame (array_shift ($ expectedWrites ), $ string );
109-
110- return true ;
111- });
112+ $ callCount = 0 ;
113+ $ response ->expects (self ::exactly (3 ))->method ('write ' )
114+ ->willReturnCallback (function ($ string ) use ($ expectedWrites , &$ callCount ) {
115+ $ this ->assertEquals ($ expectedWrites [$ callCount ], $ string );
116+ ++$ callCount ;
117+
118+ return true ;
119+ });
112120 $ response ->expects (self ::once ())->method ('end ' );
113121
114122 SymfonyHttpBridge::reflectSymfonyResponse ($ sfResponse , $ response );
0 commit comments