@@ -223,6 +223,24 @@ public function testDataEventWillBeEmittedForEmptyLine()
223223 $ this ->input ->emit ('data ' , array ("\n" ));
224224 }
225225
226+ public function testEndInputWithoutDataOnCtrlD ()
227+ {
228+ $ this ->readline ->on ('data ' , $ this ->expectCallableNever ());
229+ $ this ->readline ->on ('end ' , $ this ->expectCallableOnce ());
230+ $ this ->readline ->on ('close ' , $ this ->expectCallableOnce ());
231+
232+ $ this ->input ->emit ('data ' , array ("\x04" ));
233+ }
234+
235+ public function testEndInputWithIncompleteLineOnCtrlD ()
236+ {
237+ $ this ->readline ->on ('data ' , $ this ->expectCallableOnceWith ('hello ' ));
238+ $ this ->readline ->on ('end ' , $ this ->expectCallableOnce ());
239+ $ this ->readline ->on ('close ' , $ this ->expectCallableOnce ());
240+
241+ $ this ->input ->emit ('data ' , array ("hello \x04" ));
242+ }
243+
226244 public function testWriteSimpleCharWritesOnce ()
227245 {
228246 $ this ->output ->expects ($ this ->once ())->method ('write ' )->with ($ this ->equalTo ("\r\033[K " . "k " ));
@@ -963,9 +981,22 @@ public function testEmitErrorWillEmitErrorAndClose()
963981
964982 public function testEmitEndWillEmitEndAndClose ()
965983 {
984+ $ this ->readline ->on ('data ' , $ this ->expectCallableNever ());
985+ $ this ->readline ->on ('end ' , $ this ->expectCallableOnce ());
986+ $ this ->readline ->on ('close ' , $ this ->expectCallableOnce ());
987+
988+ $ this ->input ->emit ('end ' );
989+
990+ $ this ->assertFalse ($ this ->readline ->isReadable ());
991+ }
992+
993+ public function testEmitEndAfterDataWillEmitDataAndEndAndClose ()
994+ {
995+ $ this ->readline ->on ('data ' , $ this ->expectCallableOnce ('hello ' ));
966996 $ this ->readline ->on ('end ' , $ this ->expectCallableOnce ());
967997 $ this ->readline ->on ('close ' , $ this ->expectCallableOnce ());
968998
999+ $ this ->input ->emit ('data ' , array ('hello ' ));
9691000 $ this ->input ->emit ('end ' );
9701001
9711002 $ this ->assertFalse ($ this ->readline ->isReadable ());
0 commit comments