Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
zendframework/zendframework#6646 - stricter assertions on output to b…
Browse files Browse the repository at this point in the history
…e performed by the console prompt
  • Loading branch information
Ocramius committed Jan 3, 2015
1 parent 1831805 commit 3b575b2
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions test/Prompt/PasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ public function testCanPromptPassword()
{
$this->adapter->expects($this->at(0))->method('writeLine')->with('Password: ');
$this->adapter->expects($this->at(1))->method('readChar')->will($this->returnValue('f'));
$this->adapter->expects($this->at(2))->method('readChar')->will($this->returnValue('o'));
$this->adapter->expects($this->at(2))->method('clearLine');
$this->adapter->expects($this->at(3))->method('readChar')->will($this->returnValue('o'));
$this->adapter->expects($this->at(4))->method('readChar')->will($this->returnValue(PHP_EOL));
$this->adapter->expects($this->at(4))->method('clearLine');
$this->adapter->expects($this->at(5))->method('readChar')->will($this->returnValue('o'));
$this->adapter->expects($this->at(6))->method('clearLine');
$this->adapter->expects($this->at(7))->method('readChar')->will($this->returnValue(PHP_EOL));

$char = new Password('Password: ', false);

Expand All @@ -50,14 +53,20 @@ public function testCanPromptPasswordRepeatedly()
{
$this->adapter->expects($this->at(0))->method('writeLine')->with('New password? ');
$this->adapter->expects($this->at(1))->method('readChar')->will($this->returnValue('b'));
$this->adapter->expects($this->at(2))->method('readChar')->will($this->returnValue('a'));
$this->adapter->expects($this->at(3))->method('readChar')->will($this->returnValue('r'));
$this->adapter->expects($this->at(4))->method('readChar')->will($this->returnValue(PHP_EOL));
$this->adapter->expects($this->at(5))->method('writeLine')->with('New password? ');
$this->adapter->expects($this->at(6))->method('readChar')->will($this->returnValue('b'));
$this->adapter->expects($this->at(7))->method('readChar')->will($this->returnValue('a'));
$this->adapter->expects($this->at(8))->method('readChar')->will($this->returnValue('z'));
$this->adapter->expects($this->at(9))->method('readChar')->will($this->returnValue(PHP_EOL));
$this->adapter->expects($this->at(2))->method('clearLine');
$this->adapter->expects($this->at(3))->method('readChar')->will($this->returnValue('a'));
$this->adapter->expects($this->at(4))->method('clearLine');
$this->adapter->expects($this->at(5))->method('readChar')->will($this->returnValue('r'));
$this->adapter->expects($this->at(6))->method('clearLine');
$this->adapter->expects($this->at(7))->method('readChar')->will($this->returnValue(PHP_EOL));
$this->adapter->expects($this->at(8))->method('writeLine')->with('New password? ');
$this->adapter->expects($this->at(9))->method('readChar')->will($this->returnValue('b'));
$this->adapter->expects($this->at(10))->method('clearLine');
$this->adapter->expects($this->at(11))->method('readChar')->will($this->returnValue('a'));
$this->adapter->expects($this->at(12))->method('clearLine');
$this->adapter->expects($this->at(13))->method('readChar')->will($this->returnValue('z'));
$this->adapter->expects($this->at(14))->method('clearLine');
$this->adapter->expects($this->at(15))->method('readChar')->will($this->returnValue(PHP_EOL));

$char = new Password('New password? ', false);

Expand All @@ -81,6 +90,6 @@ public function testProducesStarSymbolOnInput()

$char->setConsole($this->adapter);

$char->show();
$this->assertSame('tab', $char->show());
}
}

0 comments on commit 3b575b2

Please sign in to comment.