@@ -40,6 +40,27 @@ public function testGetInputAfterSetting()
40
40
$ this ->assertEquals (5 , $ this ->readline ->getCursorCell ());
41
41
}
42
42
43
+ public function testAddInputAfterSetting ()
44
+ {
45
+ $ this ->readline ->setInput ('hello ' );
46
+
47
+ $ this ->assertSame ($ this ->readline , $ this ->readline ->addInput (' world ' ));
48
+ $ this ->assertEquals ('hello world ' , $ this ->readline ->getInput ());
49
+ $ this ->assertEquals (11 , $ this ->readline ->getCursorPosition ());
50
+ $ this ->assertEquals (11 , $ this ->readline ->getCursorCell ());
51
+ }
52
+
53
+ public function testAddInputAfterSettingCurrentCursorPosition ()
54
+ {
55
+ $ this ->readline ->setInput ('hello ' );
56
+ $ this ->readline ->moveCursorTo (2 );
57
+
58
+ $ this ->assertSame ($ this ->readline , $ this ->readline ->addInput ('ha ' ));
59
+ $ this ->assertEquals ('hehallo ' , $ this ->readline ->getInput ());
60
+ $ this ->assertEquals (4 , $ this ->readline ->getCursorPosition ());
61
+ $ this ->assertEquals (4 , $ this ->readline ->getCursorCell ());
62
+ }
63
+
43
64
public function testPromptAfterSetting ()
44
65
{
45
66
$ this ->assertSame ($ this ->readline , $ this ->readline ->setPrompt ('> ' ));
@@ -180,6 +201,22 @@ public function testSettingInputWithoutEchoDoesNotNeedToRedraw()
180
201
$ this ->assertSame ($ this ->readline , $ this ->readline ->setInput ('test ' ));
181
202
}
182
203
204
+ public function testAddingEmptyInputDoesNotNeedToRedraw ()
205
+ {
206
+ $ this ->output ->expects ($ this ->never ())->method ('write ' );
207
+
208
+ $ this ->assertSame ($ this ->readline , $ this ->readline ->addInput ('' ));
209
+ }
210
+
211
+ public function testAddingInputWithoutEchoDoesNotNeedToRedraw ()
212
+ {
213
+ $ this ->readline ->setEcho (false );
214
+
215
+ $ this ->output ->expects ($ this ->never ())->method ('write ' );
216
+
217
+ $ this ->assertSame ($ this ->readline , $ this ->readline ->addInput ('test ' ));
218
+ }
219
+
183
220
public function testMovingCursorWithoutEchoDoesNotNeedToRedraw ()
184
221
{
185
222
$ this ->readline ->setEcho (false );
0 commit comments