@@ -40,6 +40,27 @@ public function testGetInputAfterSetting()
4040 $ this ->assertEquals (5 , $ this ->readline ->getCursorCell ());
4141 }
4242
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+
4364 public function testPromptAfterSetting ()
4465 {
4566 $ this ->assertSame ($ this ->readline , $ this ->readline ->setPrompt ('> ' ));
@@ -180,6 +201,22 @@ public function testSettingInputWithoutEchoDoesNotNeedToRedraw()
180201 $ this ->assertSame ($ this ->readline , $ this ->readline ->setInput ('test ' ));
181202 }
182203
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+
183220 public function testMovingCursorWithoutEchoDoesNotNeedToRedraw ()
184221 {
185222 $ this ->readline ->setEcho (false );
0 commit comments