Skip to content

Commit e111575

Browse files
Test Exception via global state manipulation ($_SERVER)
1 parent 3bbd052 commit e111575

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/phpbu/Util/CliTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@
1414
*/
1515
class CliTest extends \PHPUnit_Framework_TestCase
1616
{
17+
private static $server;
18+
19+
/**
20+
* Backup $_SERVER settings.
21+
*/
22+
public function setUp()
23+
{
24+
self::$server = $_SERVER;
25+
}
26+
27+
/**
28+
* Restore $_SERVER settings.
29+
*/
30+
public function tearDown()
31+
{
32+
$_SERVER = self::$server;
33+
}
34+
1735
/**
1836
* Test detectCmdLocation Exception
1937
*
@@ -86,6 +104,19 @@ public function testDetectCmdLocationWithOptionalLocation()
86104
$this->assertEquals($cmdPath, $result, 'foo command should be found');
87105
}
88106

107+
/**
108+
* Tests Cli::getEnvPath
109+
*
110+
* @expectedException \RuntimeException
111+
*/
112+
public function testGetEnvPathFail()
113+
{
114+
unset($_SERVER['PATH']);
115+
unset($_SERVER['Path']);
116+
unset($_SERVER['path']);
117+
$path = Cli::getEnvPath();
118+
}
119+
89120
/**
90121
* Tests Cli::isAbsolutePath
91122
*/

0 commit comments

Comments
 (0)