equal
deleted
inserted
replaced
|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Assetic package, an OpenSky project. |
|
5 * |
|
6 * (c) 2010-2011 OpenSky Project Inc |
|
7 * |
|
8 * For the full copyright and license information, please view the LICENSE |
|
9 * file that was distributed with this source code. |
|
10 */ |
|
11 |
|
12 namespace Assetic\Test\Util; |
|
13 |
|
14 use Assetic\Util\ProcessBuilder; |
|
15 |
|
16 class ProcessBuilderTest extends \PHPUnit_Framework_TestCase |
|
17 { |
|
18 /** |
|
19 * @test |
|
20 */ |
|
21 public function shouldInheritEnvironmentVars() |
|
22 { |
|
23 $snapshot = $_ENV; |
|
24 $_ENV = $expected = array('foo' => 'bar'); |
|
25 |
|
26 $pb = new ProcessBuilder(); |
|
27 $pb->add('foo')->inheritEnvironmentVariables(); |
|
28 $proc = $pb->getProcess(); |
|
29 |
|
30 $this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV'); |
|
31 |
|
32 $_ENV = $snapshot; |
|
33 } |
|
34 |
|
35 /** |
|
36 * @test |
|
37 */ |
|
38 public function shouldNotReplaceExplicitlySetVars() |
|
39 { |
|
40 $snapshot = $_ENV; |
|
41 $_ENV = array('foo' => 'bar'); |
|
42 $expected = array('foo' => 'baz'); |
|
43 |
|
44 $pb = new ProcessBuilder(); |
|
45 $pb |
|
46 ->setEnv('foo', 'baz') |
|
47 ->inheritEnvironmentVariables() |
|
48 ->add('foo') |
|
49 ; |
|
50 $proc = $pb->getProcess(); |
|
51 |
|
52 $this->assertEquals($expected, $proc->getEnv(), '->inheritEnvironmentVariables() copies $_ENV'); |
|
53 |
|
54 $_ENV = $snapshot; |
|
55 } |
|
56 } |