@@ -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
}
@@ -148,15 +150,17 @@ public function testEmptyDirInPath()
148
150
{
149
151
putenv (sprintf ('PATH=%s: ' , \dirname (\PHP_BINARY )));
150
152
151
- touch ('executable ' );
152
- chmod ('executable ' , 0700 );
153
-
154
- $ finder = new ExecutableFinder ();
155
- $ result = $ finder ->find ('executable ' );
153
+ try {
154
+ touch ('executable ' );
155
+ chmod ('executable ' , 0700 );
156
156
157
- $ this ->assertSame ('./executable ' , $ result );
157
+ $ finder = new ExecutableFinder ();
158
+ $ result = $ finder ->find ('executable ' );
158
159
159
- unlink ('executable ' );
160
+ $ this ->assertSame ('./executable ' , $ result );
161
+ } finally {
162
+ unlink ('executable ' );
163
+ }
160
164
}
161
165
162
166
private function assertSamePath ($ expected , $ tested )
0 commit comments