Skip to content

Commit

Permalink
[Process] Do not throw LogicException in ProcessBuilder::getProcess i…
Browse files Browse the repository at this point in the history
…f no arguments are set but a prefix is
  • Loading branch information
romainneutron committed Apr 23, 2013
1 parent 209799b commit 1de29b9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Process/ProcessBuilder.php
Expand Up @@ -154,7 +154,7 @@ public function setOption($name, $value)

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

Expand Down
25 changes: 25 additions & 0 deletions src/Symfony/Component/Process/Tests/ProcessBuilderTest.php
Expand Up @@ -152,4 +152,29 @@ public function testShouldEscapeArgumentsAndPrefix()
$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());
}
}

0 comments on commit 1de29b9

Please sign in to comment.