@@ -311,6 +311,27 @@ public function testKeysHomeMovesToFront()
311311 return $ this ->readline ;
312312 }
313313
314+ public function testKeysHomeEmitsBellWhenAlreadyAtBeginningOfLine ()
315+ {
316+ $ this ->output ->expects ($ this ->once ())->method ('write ' )->with ("\x07" );
317+ $ this ->readline ->onKeyHome ();
318+ }
319+
320+ public function testKeysHomeDoesNotEmitBellWhenAlreadyAtBeginningOfLineButBellIsDisabled ()
321+ {
322+ $ this ->output ->expects ($ this ->never ())->method ('write ' );
323+ $ this ->readline ->setBell (false );
324+ $ this ->readline ->onKeyHome ();
325+ }
326+
327+ public function testKeysHomeEmitsBellWhenAlreadyAtBeginningOfLineAndBellIsEnabledAgain ()
328+ {
329+ $ this ->output ->expects ($ this ->once ())->method ('write ' )->with ("\x07" );
330+ $ this ->readline ->setBell (false );
331+ $ this ->readline ->setBell (true );
332+ $ this ->readline ->onKeyHome ();
333+ }
334+
314335 /**
315336 * @depends testKeysHomeMovesToFront
316337 * @param Readline $readline
@@ -324,6 +345,12 @@ public function testKeysEndMovesToEnd(Readline $readline)
324345 return $ readline ;
325346 }
326347
348+ public function testKeysEndEmitsBellWhenAlreadyAtEndOfLine ()
349+ {
350+ $ this ->output ->expects ($ this ->once ())->method ('write ' )->with ("\x07" );
351+ $ this ->readline ->onKeyEnd ();
352+ }
353+
327354 /**
328355 * @depends testKeysEndMovesToEnd
329356 * @param Readline $readline
@@ -337,6 +364,12 @@ public function testKeysLeftMovesToLeft(Readline $readline)
337364 return $ readline ;
338365 }
339366
367+ public function testKeysLeftEmitsBellWhenAlreadyAtBeginningOfLine ()
368+ {
369+ $ this ->output ->expects ($ this ->once ())->method ('write ' )->with ("\x07" );
370+ $ this ->readline ->onKeyLeft ();
371+ }
372+
340373 /**
341374 * @depends testKeysLeftMovesToLeft
342375 * @param Readline $readline
@@ -348,6 +381,12 @@ public function testKeysRightMovesToRight(Readline $readline)
348381 $ this ->assertEquals (4 , $ readline ->getCursorPosition ());
349382 }
350383
384+ public function testKeysRightEmitsBellWhenAlreadyAtEndOfLine ()
385+ {
386+ $ this ->output ->expects ($ this ->once ())->method ('write ' )->with ("\x07" );
387+ $ this ->readline ->onKeyRight ();
388+ }
389+
351390 public function testKeysSimpleChars ()
352391 {
353392 $ this ->input ->emit ('data ' , array ('hi! ' ));
@@ -372,6 +411,12 @@ public function testKeysBackspaceDeletesLastCharacter(Readline $readline)
372411 $ this ->assertEquals (2 , $ readline ->getCursorCell ());
373412 }
374413
414+ public function testKeysBackspaceEmitsBellWhenAlreadyAtBeginningOfLine ()
415+ {
416+ $ this ->output ->expects ($ this ->once ())->method ('write ' )->with ("\x07" );
417+ $ this ->readline ->onKeyBackspace ();
418+ }
419+
375420 public function testKeysMultiByteInput ()
376421 {
377422 $ this ->input ->emit ('data ' , array ('hä ' ));
@@ -430,10 +475,11 @@ public function testKeysDeleteMiddle()
430475 $ this ->assertEquals (2 , $ this ->readline ->getCursorCell ());
431476 }
432477
433- public function testKeysDeleteEndDoesNothing ()
478+ public function testKeysDeleteEmitsBellWhenAlreadyAtEndOfLine ()
434479 {
435480 $ this ->readline ->setInput ('test ' );
436481
482+ $ this ->output ->expects ($ this ->once ())->method ('write ' )->with ("\x07" );
437483 $ this ->readline ->onKeyDelete ();
438484
439485 $ this ->assertEquals ('test ' , $ this ->readline ->getInput ());
@@ -571,11 +617,9 @@ public function testAutocompleteThrowsIfNotCallable()
571617 $ this ->assertSame ($ this ->readline , $ this ->readline ->setAutocomplete (123 ));
572618 }
573619
574- /**
575- * @doesNotPerformAssertions
576- */
577- public function testAutocompleteKeyDoesNothingIfUnused ()
620+ public function testAutocompleteKeyEmitsBellWhenAutocompleteIsNotSet ()
578621 {
622+ $ this ->output ->expects ($ this ->once ())->method ('write ' )->with ("\x07" );
579623 $ this ->readline ->onKeyTab ();
580624 }
581625
@@ -784,12 +828,13 @@ public function testAutocompletePicksFirstComplete()
784828 $ this ->assertEquals ('exit ' , $ this ->readline ->getInput ());
785829 }
786830
787- public function testAutocompleteIgnoresNonMatching ()
831+ public function testAutocompleteIgnoresNonMatchingAndEmitsBell ()
788832 {
789833 $ this ->readline ->setAutocomplete (function () { return array ('quit ' ); });
790834
791835 $ this ->readline ->setInput ('e ' );
792836
837+ $ this ->output ->expects ($ this ->once ())->method ('write ' )->with ("\x07" );
793838 $ this ->readline ->onKeyTab ();
794839
795840 $ this ->assertEquals ('e ' , $ this ->readline ->getInput ());
@@ -1193,8 +1238,9 @@ public function testHistoryAddEndsUpInList()
11931238 $ this ->assertEquals (array ('a ' , 'b ' , 'c ' ), $ this ->readline ->listHistory ());
11941239 }
11951240
1196- public function testHistoryUpEmptyDoesNotChangeInput ()
1241+ public function testHistoryUpEmptyDoesNotChangeInputAndEmitsBell ()
11971242 {
1243+ $ this ->output ->expects ($ this ->once ())->method ('write ' )->with ("\x07" );
11981244 $ this ->readline ->onKeyUp ();
11991245
12001246 $ this ->assertEquals ('' , $ this ->readline ->getInput ());
@@ -1236,8 +1282,9 @@ public function testHistoryUpAndThenEnterRestoresCycleToBottom()
12361282 $ this ->assertEquals ('b ' , $ this ->readline ->getInput ());
12371283 }
12381284
1239- public function testHistoryDownNotCyclingDoesNotChangeInput ()
1285+ public function testHistoryDownNotCyclingDoesNotChangeInputAndEmitsBell ()
12401286 {
1287+ $ this ->output ->expects ($ this ->once ())->method ('write ' )->with ("\x07" );
12411288 $ this ->readline ->onKeyDown ();
12421289
12431290 $ this ->assertEquals ('' , $ this ->readline ->getInput ());
0 commit comments