@@ -461,19 +461,64 @@ public function testAskMultilineResponseWithEOF()
461
461
$ question = new Question ('Write an essay ' );
462
462
$ question ->setMultiline (true );
463
463
464
- $ this ->assertEquals ($ essay , $ dialog ->ask ($ this ->createStreamableInputInterfaceMock ($ response ), $ this ->createOutputInterface (), $ question ));
464
+ $ this ->assertSame ($ essay , $ dialog ->ask ($ this ->createStreamableInputInterfaceMock ($ response ), $ this ->createOutputInterface (), $ question ));
465
465
}
466
466
467
467
public function testAskMultilineResponseWithSingleNewline ()
468
468
{
469
- $ response = $ this ->getInputStream ("\n" );
469
+ $ response = $ this ->getInputStream (\ PHP_EOL );
470
470
471
471
$ dialog = new QuestionHelper ();
472
472
473
473
$ question = new Question ('Write an essay ' );
474
474
$ question ->setMultiline (true );
475
475
476
- $ this ->assertEquals ('' , $ dialog ->ask ($ this ->createStreamableInputInterfaceMock ($ response ), $ this ->createOutputInterface (), $ question ));
476
+ $ this ->assertNull ($ dialog ->ask ($ this ->createStreamableInputInterfaceMock ($ response ), $ this ->createOutputInterface (), $ question ));
477
+ }
478
+
479
+ public function testAskMultilineResponseWithDataAfterNewline ()
480
+ {
481
+ $ response = $ this ->getInputStream (\PHP_EOL .'this is text ' );
482
+
483
+ $ dialog = new QuestionHelper ();
484
+
485
+ $ question = new Question ('Write an essay ' );
486
+ $ question ->setMultiline (true );
487
+
488
+ $ this ->assertNull ($ dialog ->ask ($ this ->createStreamableInputInterfaceMock ($ response ), $ this ->createOutputInterface (), $ question ));
489
+ }
490
+
491
+ public function testAskMultilineResponseWithMultipleNewlinesAtEnd ()
492
+ {
493
+ $ typedText = 'This is a body ' .\PHP_EOL .\PHP_EOL ;
494
+ $ response = $ this ->getInputStream ($ typedText );
495
+
496
+ $ dialog = new QuestionHelper ();
497
+
498
+ $ question = new Question ('Write an essay ' );
499
+ $ question ->setMultiline (true );
500
+
501
+ $ this ->assertSame ('This is a body ' , $ dialog ->ask ($ this ->createStreamableInputInterfaceMock ($ response ), $ this ->createOutputInterface (), $ question ));
502
+ }
503
+
504
+ public function testAskMultilineResponseWithWithCursorInMiddleOfSeekableInputStream ()
505
+ {
506
+ $ input = <<<EOD
507
+ This
508
+ is
509
+ some
510
+ input
511
+ EOD ;
512
+ $ response = $ this ->getInputStream ($ input );
513
+ fseek ($ response , 8 );
514
+
515
+ $ dialog = new QuestionHelper ();
516
+
517
+ $ question = new Question ('Write an essay ' );
518
+ $ question ->setMultiline (true );
519
+
520
+ $ this ->assertSame ("some \ninput " , $ dialog ->ask ($ this ->createStreamableInputInterfaceMock ($ response ), $ this ->createOutputInterface (), $ question ));
521
+ $ this ->assertSame (8 , ftell ($ response ));
477
522
}
478
523
479
524
/**
0 commit comments