merged branch asm89/enhance-processbuilder (PR #5853)
This PR was squashed before being merged into the master branch (closes #5853).
Commits
-------
63b0059
[Process] Add ability to reset arguments on ProcessBuilder
Discussion
----------
[Process] Add ability to reset arguments on ProcessBuilder
Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT
This PR adds the ability to "reset" the arguments set on a `ProcessBuilder`. This allows the builder to be re-used without having to set things like custom environment variables, current working directory etc again.
This commit is contained in:
commit
8968bd0e03
@ -4,6 +4,7 @@ CHANGELOG
|
|||||||
2.2.0
|
2.2.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
* added ProcessBuilder::setArguments() to reset the arguments on a builder
|
||||||
* added a way to retrieve the standard and error output incrementally
|
* added a way to retrieve the standard and error output incrementally
|
||||||
* added Process:restart()
|
* added Process:restart()
|
||||||
|
|
||||||
|
@ -56,6 +56,18 @@ class ProcessBuilder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $arguments
|
||||||
|
*
|
||||||
|
* @return ProcessBuilder
|
||||||
|
*/
|
||||||
|
public function setArguments(array $arguments)
|
||||||
|
{
|
||||||
|
$this->arguments = $arguments;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setWorkingDirectory($cwd)
|
public function setWorkingDirectory($cwd)
|
||||||
{
|
{
|
||||||
$this->cwd = $cwd;
|
$this->cwd = $cwd;
|
||||||
|
@ -105,4 +105,14 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertNull($p->getValue($pb));
|
$this->assertNull($p->getValue($pb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testShouldSetArguments()
|
||||||
|
{
|
||||||
|
$pb = new ProcessBuilder(array('initial'));
|
||||||
|
$pb->setArguments(array('second'));
|
||||||
|
|
||||||
|
$proc = $pb->getProcess();
|
||||||
|
|
||||||
|
$this->assertContains("second", $proc->getCommandLine());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user