Ver código fonte

Expand tests for valid CLI command from script

John Kary 12 anos atrás
pai
commit
5aa3762c09
1 arquivos alterados com 17 adições e 6 exclusões
  1. 17 6
      tests/Composer/Test/Script/EventDispatcherTest.php

+ 17 - 6
tests/Composer/Test/Script/EventDispatcherTest.php

@@ -35,10 +35,12 @@ class EventDispatcherTest extends TestCase
         $dispatcher->dispatchCommandEvent("post-install-cmd");
     }
 
-    public function testDispatcherCanExecuteCommandLineScripts()
+    /**
+     * @dataProvider getValidCommands
+     * @param string $command
+     */
+    public function testDispatcherCanExecuteSingleCommandLineScript($command)
     {
-        $eventCliCommand = 'phpunit';
-
         $process = $this->getMock('Composer\Util\ProcessExecutor');
         $dispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')
             ->setConstructorArgs(array(
@@ -49,14 +51,14 @@ class EventDispatcherTest extends TestCase
             ->setMethods(array('getListeners'))
             ->getMock();
 
-        $listeners = array($eventCliCommand);
+        $listener = array($command);
         $dispatcher->expects($this->atLeastOnce())
             ->method('getListeners')
-            ->will($this->returnValue($listeners));
+            ->will($this->returnValue($listener));
 
         $process->expects($this->once())
             ->method('execute')
-            ->with($eventCliCommand);
+            ->with($command);
 
         $dispatcher->dispatchCommandEvent("post-install-cmd");
     }
@@ -78,6 +80,15 @@ class EventDispatcherTest extends TestCase
         return $dispatcher;
     }
 
+    public function getValidCommands()
+    {
+        return array(
+            array('phpunit'),
+            array('echo foo'),
+            array('echo -n foo'),
+        );
+    }
+
     public static function call()
     {
         throw new \RuntimeException();