@@ -125,18 +125,20 @@ public function testFindBatchExecutableOnWindows()
125125
126126 $ target = tempnam (sys_get_temp_dir (), 'example-windows-executable ' );
127127
128- touch ($ target );
129- touch ($ target .'.BAT ' );
130-
131- $ this ->assertFalse (is_executable ($ target ));
128+ try {
129+ touch ($ target );
130+ touch ($ target .'.BAT ' );
132131
133- putenv ( ' PATH= ' . sys_get_temp_dir ( ));
132+ $ this -> assertFalse ( is_executable ( $ target ));
134133
135- $ finder = new ExecutableFinder ();
136- $ result = $ finder ->find (basename ($ target ), false );
134+ putenv ('PATH= ' .sys_get_temp_dir ());
137135
138- unlink ($ target );
139- unlink ($ target .'.BAT ' );
136+ $ finder = new ExecutableFinder ();
137+ $ result = $ finder ->find (basename ($ target ), false );
138+ } finally {
139+ unlink ($ target );
140+ unlink ($ target .'.BAT ' );
141+ }
140142
141143 $ this ->assertSamePath ($ target .'.BAT ' , $ result );
142144 }
@@ -146,17 +148,31 @@ public function testFindBatchExecutableOnWindows()
146148 */
147149 public function testEmptyDirInPath ()
148150 {
149- putenv (sprintf ('PATH=%s: ' , \dirname (\PHP_BINARY )));
151+ putenv (sprintf ('PATH=%s%s ' , \dirname (\PHP_BINARY ), \ PATH_SEPARATOR ));
150152
151- touch ('executable ' );
152- chmod ('executable ' , 0700 );
153+ try {
154+ touch ('executable ' );
155+ chmod ('executable ' , 0700 );
153156
154- $ finder = new ExecutableFinder ();
155- $ result = $ finder ->find ('executable ' );
157+ $ finder = new ExecutableFinder ();
158+ $ result = $ finder ->find ('executable ' );
156159
157- $ this ->assertSame ('./executable ' , $ result );
160+ $ this ->assertSame ('./executable ' , $ result );
161+ } finally {
162+ unlink ('executable ' );
163+ }
164+ }
158165
159- unlink ('executable ' );
166+ public function testFindBuiltInCommandOnWindows ()
167+ {
168+ if ('\\' !== \DIRECTORY_SEPARATOR ) {
169+ $ this ->markTestSkipped ('Can be only tested on windows ' );
170+ }
171+
172+ $ finder = new ExecutableFinder ();
173+ $ this ->assertSame ('rmdir ' , strtolower ($ finder ->find ('RMDIR ' )));
174+ $ this ->assertSame ('cd ' , strtolower ($ finder ->find ('cd ' )));
175+ $ this ->assertSame ('move ' , strtolower ($ finder ->find ('MoVe ' )));
160176 }
161177
162178 private function assertSamePath ($ expected , $ tested )
0 commit comments