@@ -21,7 +21,7 @@ public function testCtorDefaultArgs()
2121 $ stdio ->close ();
2222 }
2323
24- public function testCtorArgsWillBeReturnedByGetters ()
24+ public function testCtorReadlineArgWillBeReturnedBygetReadline ()
2525 {
2626 $ input = $ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ();
2727 $ output = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
@@ -31,8 +31,6 @@ public function testCtorArgsWillBeReturnedByGetters()
3131
3232 $ stdio = new Stdio ($ this ->loop , $ input , $ output , $ readline );
3333
34- $ this ->assertSame ($ input , $ stdio ->getInput ());
35- $ this ->assertSame ($ output , $ stdio ->getOutput ());
3634 $ this ->assertSame ($ readline , $ stdio ->getReadline ());
3735 }
3836
@@ -168,77 +166,7 @@ public function testWriteAfterReadlineInputWillClearReadlineWriteOutputAndRestor
168166 $ buffer .= $ data ;
169167 }));
170168
171- $ stdio ->writeln ('test ' );
172-
173- $ this ->assertEquals ("\r\033[K " . "test \n" . "> input " , $ buffer );
174- }
175-
176- public function testOverwriteWillClearReadlineMoveToPreviousLineWriteOutputAndRestoreReadline ()
177- {
178- $ input = $ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ();
179- $ output = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
180-
181- //$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
182- $ readline = new Readline ($ input , $ output );
183- $ readline ->setPrompt ('> ' );
184- $ readline ->setInput ('input ' );
185-
186- $ stdio = new Stdio ($ this ->loop , $ input , $ output , $ readline );
187-
188- $ stdio ->write ('first ' );
189-
190- $ buffer = '' ;
191- $ output ->expects ($ this ->any ())->method ('write ' )->will ($ this ->returnCallback (function ($ data ) use (&$ buffer ) {
192- $ buffer .= $ data ;
193- }));
194-
195- $ stdio ->overwrite ('overwrite ' );
196-
197- $ this ->assertEquals ("\r\033[K " . "\033[A " . "\r\033[K " . "overwrite \n" . "> input " , $ buffer );
198- }
199-
200- public function testOverwriteAfterNewlineWillClearReadlineAndWriteOutputAndRestoreReadline ()
201- {
202- $ input = $ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ();
203- $ output = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
204-
205- //$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
206- $ readline = new Readline ($ input , $ output );
207- $ readline ->setPrompt ('> ' );
208- $ readline ->setInput ('input ' );
209-
210- $ stdio = new Stdio ($ this ->loop , $ input , $ output , $ readline );
211-
212- $ stdio ->write ("first \n" );
213-
214- $ buffer = '' ;
215- $ output ->expects ($ this ->any ())->method ('write ' )->will ($ this ->returnCallback (function ($ data ) use (&$ buffer ) {
216- $ buffer .= $ data ;
217- }));
218-
219- $ stdio ->overwrite ('overwrite ' );
220-
221- $ this ->assertEquals ("\r\033[K " . "overwrite \n" . "> input " , $ buffer );
222- }
223-
224- public function testWriteLineWillClearReadlineWriteOutputAndRestoreReadline ()
225- {
226- $ input = $ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ();
227- $ output = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
228-
229- //$readline = $this->getMockBuilder('Clue\React\Stdio\Readline')->disableOriginalConstructor()->getMock();
230- $ readline = new Readline ($ input , $ output );
231- $ readline ->setPrompt ('> ' );
232- $ readline ->setInput ('input ' );
233-
234- $ stdio = new Stdio ($ this ->loop , $ input , $ output , $ readline );
235-
236- $ buffer = '' ;
237- $ output ->expects ($ this ->any ())->method ('write ' )->will ($ this ->returnCallback (function ($ data ) use (&$ buffer ) {
238- $ buffer .= $ data ;
239- }));
240-
241- $ stdio ->writeln ('test ' );
169+ $ stdio ->write ("test \n" );
242170
243171 $ this ->assertEquals ("\r\033[K " . "test \n" . "> input " , $ buffer );
244172 }
@@ -260,8 +188,8 @@ public function testWriteTwoLinesWillClearReadlineWriteOutputAndRestoreReadline(
260188 $ buffer .= $ data ;
261189 }));
262190
263- $ stdio ->writeln ( ' hello ' );
264- $ stdio ->writeln ( ' world ' );
191+ $ stdio ->write ( " hello \n" );
192+ $ stdio ->write ( " world \n" );
265193
266194 $ this ->assertEquals ("\r\033[K " . "hello \n" . "> input " . "\r\033[K " . "world \n" . "> input " , $ buffer );
267195 }
@@ -454,7 +382,6 @@ public function testDataEventWillBeForwarded()
454382 $ stdio = new Stdio ($ this ->loop , $ input , $ output , $ readline );
455383
456384 $ stdio ->on ('data ' , $ this ->expectCallableOnceWith ("hello \n" ));
457- $ stdio ->on ('line ' , $ this ->expectCallableOnceWith ('hello ' ));
458385
459386 $ readline ->emit ('data ' , array ('hello ' ));
460387 }
0 commit comments