@@ -125,18 +125,20 @@ public function testFindBatchExecutableOnWindows()
125
125
126
126
$ target = tempnam (sys_get_temp_dir (), 'example-windows-executable ' );
127
127
128
- touch ($ target );
129
- touch ($ target .'.BAT ' );
130
-
131
- $ this ->assertFalse (is_executable ($ target ));
128
+ try {
129
+ touch ($ target );
130
+ touch ($ target .'.BAT ' );
132
131
133
- putenv ( ' PATH= ' . sys_get_temp_dir ( ));
132
+ $ this -> assertFalse ( is_executable ( $ target ));
134
133
135
- $ finder = new ExecutableFinder ();
136
- $ result = $ finder ->find (basename ($ target ), false );
134
+ putenv ('PATH= ' .sys_get_temp_dir ());
137
135
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
+ }
140
142
141
143
$ this ->assertSamePath ($ target .'.BAT ' , $ result );
142
144
}
@@ -146,17 +148,31 @@ public function testFindBatchExecutableOnWindows()
146
148
*/
147
149
public function testEmptyDirInPath ()
148
150
{
149
- putenv (sprintf ('PATH=%s: ' , \dirname (\PHP_BINARY )));
151
+ putenv (sprintf ('PATH=%s%s ' , \dirname (\PHP_BINARY ), \ PATH_SEPARATOR ));
150
152
151
- touch ('executable ' );
152
- chmod ('executable ' , 0700 );
153
+ try {
154
+ touch ('executable ' );
155
+ chmod ('executable ' , 0700 );
153
156
154
- $ finder = new ExecutableFinder ();
155
- $ result = $ finder ->find ('executable ' );
157
+ $ finder = new ExecutableFinder ();
158
+ $ result = $ finder ->find ('executable ' );
156
159
157
- $ this ->assertSame ('./executable ' , $ result );
160
+ $ this ->assertSame ('./executable ' , $ result );
161
+ } finally {
162
+ unlink ('executable ' );
163
+ }
164
+ }
158
165
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 ' )));
160
176
}
161
177
162
178
private function assertSamePath ($ expected , $ tested )
0 commit comments