[Process] Do not throw LogicException in ProcessBuilder::getProcess if no arguments are set but a prefix is

This commit is contained in:
Romain Neutron 2013-04-23 22:53:10 +02:00
parent 209799b18e
commit 1de29b9a7b
2 changed files with 26 additions and 1 deletions

View File

@ -154,7 +154,7 @@ class ProcessBuilder
public function getProcess()
{
if (!count($this->arguments)) {
if (!$this->prefix && !count($this->arguments)) {
throw new LogicException('You must add() command arguments before calling getProcess().');
}

View File

@ -152,4 +152,29 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertSame("'%prefix%' 'arg'", $proc->getCommandLine());
}
}
/**
* @expectedException \Symfony\Component\Process\Exception\LogicException
*/
public function testShouldThrowALogicExceptionIfNoPrefixAndNoArgument()
{
ProcessBuilder::create()->getProcess();
}
public function testShouldNotThrowALogicExceptionIfNoArgument()
{
$process = ProcessBuilder::create()
->setPrefix('/usr/bin/php')
->getProcess();
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
}
public function testShouldNotThrowALogicExceptionIfNoPrefix()
{
$process = ProcessBuilder::create(array('/usr/bin/php'))
->getProcess();
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
}
}