From 5aa3762c0998c6a2c4da6fff10b549fc69ae8318 Mon Sep 17 00:00:00 2001 From: John Kary Date: Sat, 6 Oct 2012 21:54:52 -0500 Subject: [PATCH] Expand tests for valid CLI command from script --- .../Test/Script/EventDispatcherTest.php | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/Composer/Test/Script/EventDispatcherTest.php b/tests/Composer/Test/Script/EventDispatcherTest.php index 682624d9f..c6bfc710c 100644 --- a/tests/Composer/Test/Script/EventDispatcherTest.php +++ b/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();