Permalink
Browse files

[Process] Do not throw LogicException in ProcessBuilder::getProcess i…

…f no arguments are set but a prefix is
  • Loading branch information...
1 parent 6e1fe78 commit a2a22e359c8c6c6a44ec2d158d0865e9a94348b1 @romainneutron romainneutron committed Apr 23, 2013
Showing with 26 additions and 1 deletion.
  1. +1 −1 ProcessBuilder.php
  2. +25 −0 Tests/ProcessBuilderTest.php
View
@@ -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().');
}
@@ -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 a2a22e3

Please sign in to comment.