Expand tests for valid CLI command from script
parent
b213e585df
commit
5aa3762c09
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue