d7712a3e2a
This class was copied from Assetic.
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Tests\Component\Process;
|
|
|
|
use Symfony\Component\Process\ProcessBuilder;
|
|
|
|
class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
/**
|
|
* @test
|
|
*/
|
|
public function shouldInheritEnvironmentVars()
|
|
{
|
|
$snapshot = $_ENV;
|
|
$_ENV = $expected = array('foo' => 'bar');
|
|
|
|
$pb = new ProcessBuilder();
|
|
$pb->add('foo')->inheritEnvironmentVariables();
|
|
$proc = $pb->getProcess();
|
|
|
|
$this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV');
|
|
|
|
$_ENV = $snapshot;
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function shouldNotReplaceExplicitlySetVars()
|
|
{
|
|
$snapshot = $_ENV;
|
|
$_ENV = array('foo' => 'bar');
|
|
$expected = array('foo' => 'baz');
|
|
|
|
$pb = new ProcessBuilder();
|
|
$pb
|
|
->setEnv('foo', 'baz')
|
|
->inheritEnvironmentVariables()
|
|
->add('foo')
|
|
;
|
|
$proc = $pb->getProcess();
|
|
|
|
$this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV');
|
|
|
|
$_ENV = $snapshot;
|
|
}
|
|
}
|