@@ -36,46 +36,21 @@ public function requestShouldBindToStreamEventsAndUseconnector()
3636
3737 $ this ->successfulConnectionMock ();
3838
39- $ this ->stream
40- ->expects ($ this ->at (0 ))
41- ->method ('on ' )
42- ->with ('drain ' , $ this ->identicalTo (array ($ request , 'handleDrain ' )));
43- $ this ->stream
44- ->expects ($ this ->at (1 ))
45- ->method ('on ' )
46- ->with ('data ' , $ this ->identicalTo (array ($ request , 'handleData ' )));
47- $ this ->stream
48- ->expects ($ this ->at (2 ))
49- ->method ('on ' )
50- ->with ('end ' , $ this ->identicalTo (array ($ request , 'handleEnd ' )));
51- $ this ->stream
52- ->expects ($ this ->at (3 ))
53- ->method ('on ' )
54- ->with ('error ' , $ this ->identicalTo (array ($ request , 'handleError ' )));
55- $ this ->stream
56- ->expects ($ this ->at (4 ))
57- ->method ('on ' )
58- ->with ('close ' , $ this ->identicalTo (array ($ request , 'handleClose ' )));
59- $ this ->stream
60- ->expects ($ this ->at (6 ))
61- ->method ('removeListener ' )
62- ->with ('drain ' , $ this ->identicalTo (array ($ request , 'handleDrain ' )));
63- $ this ->stream
64- ->expects ($ this ->at (7 ))
65- ->method ('removeListener ' )
66- ->with ('data ' , $ this ->identicalTo (array ($ request , 'handleData ' )));
67- $ this ->stream
68- ->expects ($ this ->at (8 ))
69- ->method ('removeListener ' )
70- ->with ('end ' , $ this ->identicalTo (array ($ request , 'handleEnd ' )));
71- $ this ->stream
72- ->expects ($ this ->at (9 ))
73- ->method ('removeListener ' )
74- ->with ('error ' , $ this ->identicalTo (array ($ request , 'handleError ' )));
75- $ this ->stream
76- ->expects ($ this ->at (10 ))
77- ->method ('removeListener ' )
78- ->with ('close ' , $ this ->identicalTo (array ($ request , 'handleClose ' )));
39+ $ this ->stream ->expects ($ this ->exactly (6 ))->method ('on ' )->withConsecutive (
40+ array ('drain ' , $ this ->identicalTo (array ($ request , 'handleDrain ' ))),
41+ array ('data ' , $ this ->identicalTo (array ($ request , 'handleData ' ))),
42+ array ('end ' , $ this ->identicalTo (array ($ request , 'handleEnd ' ))),
43+ array ('error ' , $ this ->identicalTo (array ($ request , 'handleError ' ))),
44+ array ('close ' , $ this ->identicalTo (array ($ request , 'handleClose ' )))
45+ );
46+
47+ $ this ->stream ->expects ($ this ->exactly (5 ))->method ('removeListener ' )->withConsecutive (
48+ array ('drain ' , $ this ->identicalTo (array ($ request , 'handleDrain ' ))),
49+ array ('data ' , $ this ->identicalTo (array ($ request , 'handleData ' ))),
50+ array ('end ' , $ this ->identicalTo (array ($ request , 'handleEnd ' ))),
51+ array ('error ' , $ this ->identicalTo (array ($ request , 'handleError ' ))),
52+ array ('close ' , $ this ->identicalTo (array ($ request , 'handleClose ' )))
53+ );
7954
8055 $ request ->on ('end ' , $ this ->expectCallableNever ());
8156
@@ -223,18 +198,11 @@ public function writeWithAPostRequestShouldSendToTheStream()
223198
224199 $ this ->successfulConnectionMock ();
225200
226- $ this ->stream
227- ->expects ($ this ->at (5 ))
228- ->method ('write ' )
229- ->with ($ this ->matchesRegularExpression ("#^POST / HTTP/1\.0 \r\nHost: www.example.com \r\nUser-Agent:.* \r\n\r\nsome$# " ));
230- $ this ->stream
231- ->expects ($ this ->at (6 ))
232- ->method ('write ' )
233- ->with ($ this ->identicalTo ("post " ));
234- $ this ->stream
235- ->expects ($ this ->at (7 ))
236- ->method ('write ' )
237- ->with ($ this ->identicalTo ("data " ));
201+ $ this ->stream ->expects ($ this ->exactly (3 ))->method ('write ' )->withConsecutive (
202+ array ($ this ->matchesRegularExpression ("#^POST / HTTP/1\.0 \r\nHost: www.example.com \r\nUser-Agent:.* \r\n\r\nsome$# " )),
203+ array ($ this ->identicalTo ("post " )),
204+ array ($ this ->identicalTo ("data " ))
205+ );
238206
239207 $ request ->write ("some " );
240208 $ request ->write ("post " );
@@ -253,15 +221,12 @@ public function writeWithAPostRequestShouldSendBodyAfterHeadersAndEmitDrainEvent
253221
254222 $ resolveConnection = $ this ->successfulAsyncConnectionMock ();
255223
256- $ this ->stream
257- ->expects ($ this ->at (5 ))
258- ->method ('write ' )
259- ->with ($ this ->matchesRegularExpression ("#^POST / HTTP/1\.0 \r\nHost: www.example.com \r\nUser-Agent:.* \r\n\r\nsomepost$# " ))
260- ->willReturn (true );
261- $ this ->stream
262- ->expects ($ this ->at (6 ))
263- ->method ('write ' )
264- ->with ($ this ->identicalTo ("data " ));
224+ $ this ->stream ->expects ($ this ->exactly (2 ))->method ('write ' )->withConsecutive (
225+ array ($ this ->matchesRegularExpression ("#^POST / HTTP/1\.0 \r\nHost: www.example.com \r\nUser-Agent:.* \r\n\r\nsomepost$# " )),
226+ array ($ this ->identicalTo ("data " ))
227+ )->willReturn (
228+ true
229+ );
265230
266231 $ this ->assertFalse ($ request ->write ("some " ));
267232 $ this ->assertFalse ($ request ->write ("post " ));
@@ -292,15 +257,12 @@ public function writeWithAPostRequestShouldForwardDrainEventIfFirstChunkExceedsB
292257
293258 $ resolveConnection = $ this ->successfulAsyncConnectionMock ();
294259
295- $ this ->stream
296- ->expects ($ this ->at (0 ))
297- ->method ('write ' )
298- ->with ($ this ->matchesRegularExpression ("#^POST / HTTP/1\.0 \r\nHost: www.example.com \r\nUser-Agent:.* \r\n\r\nsomepost$# " ))
299- ->willReturn (false );
300- $ this ->stream
301- ->expects ($ this ->at (1 ))
302- ->method ('write ' )
303- ->with ($ this ->identicalTo ("data " ));
260+ $ this ->stream ->expects ($ this ->exactly (2 ))->method ('write ' )->withConsecutive (
261+ array ($ this ->matchesRegularExpression ("#^POST / HTTP/1\.0 \r\nHost: www.example.com \r\nUser-Agent:.* \r\n\r\nsomepost$# " )),
262+ array ($ this ->identicalTo ("data " ))
263+ )->willReturn (
264+ false
265+ );
304266
305267 $ this ->assertFalse ($ request ->write ("some " ));
306268 $ this ->assertFalse ($ request ->write ("post " ));
@@ -327,18 +289,11 @@ public function pipeShouldPipeDataIntoTheRequestBody()
327289
328290 $ this ->successfulConnectionMock ();
329291
330- $ this ->stream
331- ->expects ($ this ->at (5 ))
332- ->method ('write ' )
333- ->with ($ this ->matchesRegularExpression ("#^POST / HTTP/1\.0 \r\nHost: www.example.com \r\nUser-Agent:.* \r\n\r\nsome$# " ));
334- $ this ->stream
335- ->expects ($ this ->at (6 ))
336- ->method ('write ' )
337- ->with ($ this ->identicalTo ("post " ));
338- $ this ->stream
339- ->expects ($ this ->at (7 ))
340- ->method ('write ' )
341- ->with ($ this ->identicalTo ("data " ));
292+ $ this ->stream ->expects ($ this ->exactly (3 ))->method ('write ' )->withConsecutive (
293+ array ($ this ->matchesRegularExpression ("#^POST / HTTP/1\.0 \r\nHost: www.example.com \r\nUser-Agent:.* \r\n\r\nsome$# " )),
294+ array ($ this ->identicalTo ("post " )),
295+ array ($ this ->identicalTo ("data " ))
296+ );
342297
343298 $ loop = $ this
344299 ->getMockBuilder ('React\EventLoop\LoopInterface ' )
0 commit comments