[Process] Added ProcessBuilder::addEnvironmentVariables
This commit is contained in:
parent
35bdf823c4
commit
b46ebf79b1
@ -108,6 +108,13 @@ class ProcessBuilder
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addEnvironmentVariables(array $variables)
|
||||
{
|
||||
$this->env = array_replace($this->env, $variables);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setInput($stdin)
|
||||
{
|
||||
$this->stdin = $stdin;
|
||||
|
@ -53,6 +53,23 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNull($proc->getEnv());
|
||||
}
|
||||
|
||||
public function testAddEnvironmentVariables()
|
||||
{
|
||||
$pb = new ProcessBuilder();
|
||||
$env = array(
|
||||
'foo' => 'bar',
|
||||
'foo2' => 'bar2',
|
||||
);
|
||||
$proc = $pb
|
||||
->add('command')
|
||||
->setEnv('foo', 'bar2')
|
||||
->addEnvironmentVariables($env)
|
||||
->getProcess()
|
||||
;
|
||||
|
||||
$this->assertSame($env, $proc->getEnv());
|
||||
}
|
||||
|
||||
public function testNotReplaceExplicitlySetVars()
|
||||
{
|
||||
$snapshot = $_ENV;
|
||||
|
Reference in New Issue
Block a user