[Process] Do not throw LogicException in ProcessBuilder::getProcess if no arguments are set but a prefix is
This commit is contained in:
parent
209799b18e
commit
1de29b9a7b
@ -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().');
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user