@@ -21,7 +21,7 @@ public function testCtorDefaultArgs()
21
21
$ stdio ->close ();
22
22
}
23
23
24
- public function testCtorArgsWillBeReturnedByGetters ()
24
+ public function testCtorReadlineArgWillBeReturnedBygetReadline ()
25
25
{
26
26
$ input = $ this ->getMockBuilder ('React\Stream\ReadableStreamInterface ' )->getMock ();
27
27
$ output = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
@@ -31,8 +31,6 @@ public function testCtorArgsWillBeReturnedByGetters()
31
31
32
32
$ stdio = new Stdio ($ this ->loop , $ input , $ output , $ readline );
33
33
34
- $ this ->assertSame ($ input , $ stdio ->getInput ());
35
- $ this ->assertSame ($ output , $ stdio ->getOutput ());
36
34
$ this ->assertSame ($ readline , $ stdio ->getReadline ());
37
35
}
38
36
@@ -168,77 +166,7 @@ public function testWriteAfterReadlineInputWillClearReadlineWriteOutputAndRestor
168
166
$ buffer .= $ data ;
169
167
}));
170
168
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" );
242
170
243
171
$ this ->assertEquals ("\r\033[K " . "test \n" . "> input " , $ buffer );
244
172
}
@@ -260,8 +188,8 @@ public function testWriteTwoLinesWillClearReadlineWriteOutputAndRestoreReadline(
260
188
$ buffer .= $ data ;
261
189
}));
262
190
263
- $ stdio ->writeln ( ' hello ' );
264
- $ stdio ->writeln ( ' world ' );
191
+ $ stdio ->write ( " hello \n" );
192
+ $ stdio ->write ( " world \n" );
265
193
266
194
$ this ->assertEquals ("\r\033[K " . "hello \n" . "> input " . "\r\033[K " . "world \n" . "> input " , $ buffer );
267
195
}
@@ -454,7 +382,6 @@ public function testDataEventWillBeForwarded()
454
382
$ stdio = new Stdio ($ this ->loop , $ input , $ output , $ readline );
455
383
456
384
$ stdio ->on ('data ' , $ this ->expectCallableOnceWith ("hello \n" ));
457
- $ stdio ->on ('line ' , $ this ->expectCallableOnceWith ('hello ' ));
458
385
459
386
$ readline ->emit ('data ' , array ('hello ' ));
460
387
}
0 commit comments