@@ -42,6 +42,25 @@ public function testSettingInputMovesCursorToEnd()
4242 $ this ->assertEquals (7 , $ this ->readline ->getCursorCell ());
4343 }
4444
45+ public function testSettingMoveOffDoesNotAllowDirectionKeysToChangePosition ()
46+ {
47+ $ this ->readline ->setInput ('test ' );
48+ $ this ->readline ->setMove (false );
49+ $ this ->readline ->moveCursorTo (2 );
50+
51+ $ this ->readline ->onKeyLeft ();
52+ $ this ->assertEquals (2 , $ this ->readline ->getCursorPosition ());
53+
54+ $ this ->readline ->onKeyRight ();
55+ $ this ->assertEquals (2 , $ this ->readline ->getCursorPosition ());
56+
57+ $ this ->readline ->onKeyHome ();
58+ $ this ->assertEquals (2 , $ this ->readline ->getCursorPosition ());
59+
60+ $ this ->readline ->onKeyEnd ();
61+ $ this ->assertEquals (2 , $ this ->readline ->getCursorPosition ());
62+ }
63+
4564 public function testMultiByteInput ()
4665 {
4766 $ this ->readline ->setInput ('täst ' );
@@ -192,6 +211,32 @@ public function testKeysEndMovesToEnd(Readline $readline)
192211 $ readline ->onKeyEnd ();
193212
194213 $ this ->assertEquals (4 , $ readline ->getCursorPosition ());
214+
215+ return $ readline ;
216+ }
217+
218+ /**
219+ * @depends testKeysEndMovesToEnd
220+ * @param Readline $readline
221+ */
222+ public function testKeysLeftMovesToLeft (Readline $ readline )
223+ {
224+ $ readline ->onKeyLeft ();
225+
226+ $ this ->assertEquals (3 , $ readline ->getCursorPosition ());
227+
228+ return $ readline ;
229+ }
230+
231+ /**
232+ * @depends testKeysLeftMovesToLeft
233+ * @param Readline $readline
234+ */
235+ public function testKeysRightMovesToRight (Readline $ readline )
236+ {
237+ $ readline ->onKeyRight ();
238+
239+ $ this ->assertEquals (4 , $ readline ->getCursorPosition ());
195240 }
196241
197242 public function testKeysSimpleChars ()
0 commit comments