@@ -483,6 +483,75 @@ public function testSetInputDuringEmitKeepsInput()
483483 $ this ->assertEquals ('test ' , $ readline ->getInput ());
484484 }
485485
486+ public function testEmitErrorWillEmitErrorAndClose ()
487+ {
488+ $ this ->readline ->on ('error ' , $ this ->expectCallableOnce ());
489+ $ this ->readline ->on ('close ' , $ this ->expectCallableOnce ());
490+
491+ $ this ->input ->emit ('error ' , array (new \RuntimeException ()));
492+
493+ $ this ->assertFalse ($ this ->readline ->isReadable ());
494+ }
495+
496+ public function testEmitEndWillEmitEndAndClose ()
497+ {
498+ $ this ->readline ->on ('end ' , $ this ->expectCallableOnce ());
499+ $ this ->readline ->on ('close ' , $ this ->expectCallableOnce ());
500+
501+ $ this ->input ->emit ('end ' );
502+
503+ $ this ->assertFalse ($ this ->readline ->isReadable ());
504+ }
505+
506+ public function testEmitCloseWillEmitClose ()
507+ {
508+ $ this ->readline ->on ('end ' , $ this ->expectCallableNever ());
509+ $ this ->readline ->on ('close ' , $ this ->expectCallableOnce ());
510+
511+ $ this ->input ->emit ('close ' );
512+
513+ $ this ->assertFalse ($ this ->readline ->isReadable ());
514+ }
515+
516+ public function testClosedStdinWillCloseReadline ()
517+ {
518+ $ this ->input = $ this ->getMock ('React\Stream\ReadableStreamInterface ' );
519+ $ this ->input ->expects ($ this ->once ())->method ('isReadable ' )->willReturn (false );
520+
521+ $ this ->readline = new Readline ($ this ->input , $ this ->output );
522+
523+ $ this ->assertFalse ($ this ->readline ->isReadable ());
524+ }
525+
526+ public function testPauseWillBeForwarded ()
527+ {
528+ $ this ->input = $ this ->getMock ('React\Stream\ReadableStreamInterface ' );
529+ $ this ->input ->expects ($ this ->once ())->method ('pause ' );
530+
531+ $ this ->readline = new Readline ($ this ->input , $ this ->output );
532+
533+ $ this ->readline ->pause ();
534+ }
535+
536+ public function testResumeWillBeForwarded ()
537+ {
538+ $ this ->input = $ this ->getMock ('React\Stream\ReadableStreamInterface ' );
539+ $ this ->input ->expects ($ this ->once ())->method ('resume ' );
540+
541+ $ this ->readline = new Readline ($ this ->input , $ this ->output );
542+
543+ $ this ->readline ->resume ();
544+ }
545+
546+ public function testPipeWillReturnDest ()
547+ {
548+ $ dest = $ this ->getMock ('React\Stream\WritableStreamInterface ' );
549+
550+ $ ret = $ this ->readline ->pipe ($ dest );
551+
552+ $ this ->assertEquals ($ dest , $ ret );
553+ }
554+
486555 private function pushInputBytes (Readline $ readline , $ bytes )
487556 {
488557 foreach (str_split ($ bytes , 1 ) as $ byte ) {
0 commit comments