@@ -72,11 +72,21 @@ public function testThatSymfonyResponseIsReflected(): void
7272 $ sfResponse ->expects (self ::once ())->method ('getContent ' )->willReturn ('Test ' );
7373
7474 $ response = $ this ->createMock (Response::class);
75- $ response -> expects ( self :: exactly ( 3 ))-> method ( ' header ' )-> withConsecutive (
75+ $ expectedHeaders = [
7676 ['x-test ' , 'Swoole-Runtime ' ],
7777 ['set-cookie ' , $ fooCookie ],
78- ['set-cookie ' , $ barCookie ]
79- );
78+ ['set-cookie ' , $ barCookie ],
79+ ];
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+ });
8090 $ response ->expects (self ::once ())->method ('status ' )->with (201 );
8191 $ response ->expects (self ::once ())->method ('end ' )->with ('Test ' );
8292
@@ -94,7 +104,19 @@ public function testThatSymfonyStreamedResponseIsReflected(): void
94104 });
95105
96106 $ response = $ this ->createMock (Response::class);
97- $ response ->expects (self ::exactly (3 ))->method ('write ' )->withConsecutive (["Foo \n" ], ["Bar \n" ], ['' ]);
107+ $ expectedWrites = [
108+ "Foo \n" ,
109+ "Bar \n" ,
110+ '' ,
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+ });
98120 $ response ->expects (self ::once ())->method ('end ' );
99121
100122 SymfonyHttpBridge::reflectSymfonyResponse ($ sfResponse , $ response );
0 commit comments