1
0
Fork 0

Expand tests for valid CLI command from script

pull/1186/head
John Kary 2012-10-06 21:54:52 -05:00
parent b213e585df
commit 5aa3762c09
1 changed files with 17 additions and 6 deletions

View File

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