From cc793eff6f8b4757e15f9901908314c08be89a4e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 6 May 2016 00:28:45 +0100 Subject: [PATCH] Clean up ApplicationTest --- tests/Composer/Test/ApplicationTest.php | 33 ++++++++++++++++++------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/tests/Composer/Test/ApplicationTest.php b/tests/Composer/Test/ApplicationTest.php index b977b78e0558..deb763c629cc 100644 --- a/tests/Composer/Test/ApplicationTest.php +++ b/tests/Composer/Test/ApplicationTest.php @@ -25,15 +25,21 @@ public function testDevWarning() $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - $inputMock->expects($this->any()) - ->method('hasParameterOption') - ->with($this->equalTo('--no-plugins')) - ->will($this->returnValue(true)); + $index = 0; + $inputMock->expects($this->at($index++)) + ->method('getParameterOption') + ->with($this->equalTo(array('--working-dir', '-d'))) + ->will($this->returnValue(false)); - $inputMock->expects($this->any()) + $inputMock->expects($this->at($index++)) ->method('getFirstArgument') ->will($this->returnValue('list')); + $inputMock->expects($this->at($index++)) + ->method('hasParameterOption') + ->with($this->equalTo('--no-plugins')) + ->will($this->returnValue(true)); + $index = 0; $outputMock->expects($this->at($index++)) ->method("writeError"); @@ -60,7 +66,6 @@ public function testDevWarning() define('COMPOSER_DEV_WARNING_TIME', time() - 1); } - $this->setExpectedException('RuntimeException'); $application->doRun($inputMock, $outputMock); } @@ -73,9 +78,20 @@ public function ensureNoDevWarning($command) $inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - $inputMock->expects($this->any()) + $index = 0; + $inputMock->expects($this->at($index++)) + ->method('getParameterOption') + ->with($this->equalTo(array('--working-dir', '-d'))) + ->will($this->returnValue(false)); + + $inputMock->expects($this->at($index++)) ->method('getFirstArgument') - ->will($this->returnValue($command)); + ->will($this->returnValue('list')); + + $inputMock->expects($this->at($index++)) + ->method('hasParameterOption') + ->with($this->equalTo('--no-plugins')) + ->will($this->returnValue(true)); $outputMock->expects($this->never()) ->method("writeln"); @@ -84,7 +100,6 @@ public function ensureNoDevWarning($command) define('COMPOSER_DEV_WARNING_TIME', time() - 1); } - $this->setExpectedException('RuntimeException'); $application->doRun($inputMock, $outputMock); }