@@ -285,7 +285,7 @@ public function testWritableWillBeForwardedToOutput()
285285 $ this ->assertTrue ($ stdio ->isWritable ());
286286 }
287287
288- public function testCloseWillCloseInputAndOutput ()
288+ public function testCloseWillEmitCloseEventAndCloseInputAndOutput ()
289289 {
290290 $ input = $ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ();
291291 $ output = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
@@ -295,13 +295,17 @@ public function testCloseWillCloseInputAndOutput()
295295
296296 $ stdio = new Stdio ($ this ->loop , $ input , $ output , $ readline );
297297
298+ $ stdio ->on ('close ' , $ this ->expectCallableOnce ());
299+
298300 $ input ->expects ($ this ->once ())->method ('close ' );
299301 $ output ->expects ($ this ->once ())->method ('close ' );
300302
301303 $ stdio ->close ();
304+
305+ $ this ->assertEquals (array (), $ stdio ->listeners ('close ' ));
302306 }
303307
304- public function testCloseTwiceWillCloseInputAndOutputOnlyOnce ()
308+ public function testCloseTwiceWillEmitCloseEventAndCloseInputAndOutputOnlyOnce ()
305309 {
306310 $ input = $ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ();
307311 $ output = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
@@ -311,20 +315,23 @@ public function testCloseTwiceWillCloseInputAndOutputOnlyOnce()
311315
312316 $ stdio = new Stdio ($ this ->loop , $ input , $ output , $ readline );
313317
318+ $ stdio ->on ('close ' , $ this ->expectCallableOnce ());
319+
314320 $ input ->expects ($ this ->once ())->method ('close ' );
315321 $ output ->expects ($ this ->once ())->method ('close ' );
316322
317323 $ stdio ->close ();
318324 $ stdio ->close ();
319325 }
320326
321- public function testEndWillCloseInputAndEndOutput ()
327+ public function testEndWillClearReadlineAndCloseInputAndEndOutput ()
322328 {
323329 $ input = $ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ();
324330 $ output = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
325331
326- //$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
327- $ readline = new Readline ($ input , $ output );
332+ $ readline = $ this ->getMockBuilder ('Clue\React\Stdio\Readline ' )->disableOriginalConstructor ()->getMock ();
333+ $ readline ->expects ($ this ->once ())->method ('setPrompt ' )->with ('' )->willReturnSelf ();
334+ $ readline ->expects ($ this ->once ())->method ('setInput ' )->with ('' )->willReturnSelf ();
328335
329336 $ stdio = new Stdio ($ this ->loop , $ input , $ output , $ readline );
330337
0 commit comments