1919 */
2020class ExecutableFinderTest extends TestCase
2121{
22- private string |false $ path = false ;
23-
2422 protected function tearDown (): void
2523 {
26- if ($ this ->path ) {
27- // Restore path if it was changed.
28- putenv ('PATH= ' .$ this ->path );
29- }
30- }
31-
32- private function setPath ($ path )
33- {
34- $ this ->path = getenv ('PATH ' );
35- putenv ('PATH= ' .$ path );
24+ putenv ('PATH= ' .($ _SERVER ['PATH ' ] ?? $ _SERVER ['Path ' ]));
3625 }
3726
3827 public function testFind ()
@@ -41,7 +30,7 @@ public function testFind()
4130 $ this ->markTestSkipped ('Cannot test when open_basedir is set ' );
4231 }
4332
44- $ this -> setPath ( \dirname (\PHP_BINARY ));
33+ putenv ( ' PATH= ' . \dirname (\PHP_BINARY ));
4534
4635 $ finder = new ExecutableFinder ();
4736 $ result = $ finder ->find ($ this ->getPhpBinaryName ());
@@ -57,7 +46,7 @@ public function testFindWithDefault()
5746
5847 $ expected = 'defaultValue ' ;
5948
60- $ this -> setPath ( ' ' );
49+ putenv ( ' PATH= ' );
6150
6251 $ finder = new ExecutableFinder ();
6352 $ result = $ finder ->find ('foo ' , $ expected );
@@ -71,7 +60,7 @@ public function testFindWithNullAsDefault()
7160 $ this ->markTestSkipped ('Cannot test when open_basedir is set ' );
7261 }
7362
74- $ this -> setPath ( ' ' );
63+ putenv ( ' PATH= ' );
7564
7665 $ finder = new ExecutableFinder ();
7766
@@ -86,7 +75,7 @@ public function testFindWithExtraDirs()
8675 $ this ->markTestSkipped ('Cannot test when open_basedir is set ' );
8776 }
8877
89- $ this -> setPath ( ' ' );
78+ putenv ( ' PATH= ' );
9079
9180 $ extraDirs = [\dirname (\PHP_BINARY )];
9281
@@ -129,7 +118,6 @@ public function testFindProcessInOpenBasedir()
129118 $ this ->markTestSkipped ('Cannot run test on windows ' );
130119 }
131120
132- $ this ->setPath ('' );
133121 $ this ->iniSet ('open_basedir ' , \PHP_BINARY .\PATH_SEPARATOR .'/ ' );
134122
135123 $ finder = new ExecutableFinder ();
@@ -154,7 +142,7 @@ public function testFindBatchExecutableOnWindows()
154142
155143 $ this ->assertFalse (is_executable ($ target ));
156144
157- $ this -> setPath ( sys_get_temp_dir ());
145+ putenv ( ' PATH= ' . sys_get_temp_dir ());
158146
159147 $ finder = new ExecutableFinder ();
160148 $ result = $ finder ->find (basename ($ target ), false );
0 commit comments