Browse Source

Clean up ApplicationTest

Jordi Boggiano 8 years ago
parent
commit
1aa31caec5
1 changed files with 24 additions and 9 deletions
  1. 24 9
      tests/Composer/Test/ApplicationTest.php

+ 24 - 9
tests/Composer/Test/ApplicationTest.php

@@ -25,15 +25,21 @@ class ApplicationTest extends TestCase
         $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 @@ class ApplicationTest extends TestCase
             define('COMPOSER_DEV_WARNING_TIME', time() - 1);
         }
 
-        $this->setExpectedException('RuntimeException');
         $application->doRun($inputMock, $outputMock);
     }
 
@@ -73,9 +78,20 @@ class ApplicationTest extends TestCase
         $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 @@ class ApplicationTest extends TestCase
             define('COMPOSER_DEV_WARNING_TIME', time() - 1);
         }
 
-        $this->setExpectedException('RuntimeException');
         $application->doRun($inputMock, $outputMock);
     }