@@ -285,7 +285,7 @@ public function testWritableWillBeForwardedToOutput()
285
285
$ this ->assertTrue ($ stdio ->isWritable ());
286
286
}
287
287
288
- public function testCloseWillCloseInputAndOutput ()
288
+ public function testCloseWillEmitCloseEventAndCloseInputAndOutput ()
289
289
{
290
290
$ input = $ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ();
291
291
$ output = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
@@ -295,13 +295,17 @@ public function testCloseWillCloseInputAndOutput()
295
295
8000
296
296
$ stdio = new Stdio ($ this ->loop , $ input , $ output , $ readline );
297
297
298
+ $ stdio ->on ('close ' , $ this ->expectCallableOnce ());
299
+
298
300
$ input ->expects ($ this ->once ())->method ('close ' );
299
301
$ output ->expects ($ this ->once ())->method ('close ' );
300
302
301
303
$ stdio ->close ();
304
+
305
+ $ this ->assertEquals (array (), $ stdio ->listeners ('close ' ));
302
306
}
303
307
304
- public function testCloseTwiceWillCloseInputAndOutputOnlyOnce ()
308
+ public function testCloseTwiceWillEmitCloseEventAndCloseInputAndOutputOnlyOnce ()
305
309
{
306
310
$ input = $ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ();
307
311
$ output = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
@@ -311,20 +315,23 @@ public function testCloseTwiceWillCloseInputAndOutputOnlyOnce()
311
315
312
316
$ stdio = new Stdio ($ this ->loop , $ input , $ output , $ readline );
313
317
318
+ $ stdio ->on ('close ' , $ this ->expectCallableOnce ());
319
+
314
320
$ input ->expects ($ this ->once ())->method ('close ' );
315
321
$ output ->expects ($ this ->once ())->method ('close ' );
316
322
317
323
$ stdio ->close ();
318
324
$ stdio ->close ();
319
325
}
320
326
321
- public function testEndWillCloseInputAndEndOutput ()
327
+ public function testEndWillClearReadlineAndCloseInputAndEndOutput ()
322
328
{
323
329
$ input = $ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ();
324
330
$ output = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
325
331
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 ();
328
335
329
336
$ stdio = new Stdio ($ this ->loop , $ input , $ output , $ readline );
330
337
0 commit comments