8000 [Process] Do not throw LogicException in ProcessBuilder::getProcess i… · norberttech/symfony@1de29b9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1de29b9

Browse files
committed
[Process] Do not throw LogicException in ProcessBuilder::getProcess if no arguments are set but a prefix is
1 parent 209799b commit 1de29b9

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/Symfony/Component/Process/ProcessBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function setOption($name, $value)
154154

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

src/Symfony/Component/Process/Tests/ProcessBuilderTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,29 @@ public function testShouldEscapeArgumentsAndPrefix()
152152
$this->assertSame("'%prefix%' 'arg'", $proc->getCommandLine());
153153
}
154154
}
155+
156+
/**
157+
* @expectedException \Symfony\Component\Process\Exception\LogicException
158+
*/
159+
public function testShouldThrowALogicExceptionIfNoPrefixAndNoArgument()
160+
{
161+
ProcessBuilder::create()->getProcess();
162+
}
163+
164+
public function testShouldNotThrowALogicExceptionIfNoArgument()
165+
{
166+
$process = ProcessBuilder::create()
167+
->setPrefix('/usr/bin/php')
168+
->getProcess();
169+
170+
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
171+
}
172+
173+
public function testShouldNotThrowALogicExceptionIfNoPrefix()
174+
{
175+
$process = ProcessBuilder::create(array('/usr/bin/php'))
176+
->getProcess();
177+
178+
$this->assertEquals("'/usr/bin/php'", $process->getCommandLine());
179+
}
155180
}

0 commit comments

Comments
 (0)
0