Re: Some spl tests fail on windows as of unlink error
| From: | Johannes Schlüter | Date: | Thu, 09 Dec 2010 12:44:26 +0000 |
| Subject: | Re: Some spl tests fail on windows as of unlink error | ||
| References: | 1 | Groups: | php.qa |
| Request: | Send a blank email to php-qa+get-65707@lists.php.net to get a copy of this message | ||
On Thu, 2010-12-09 at 14:29 +0200, Eyal Teutsch wrote:
> 1 <?php
> 2 $file = dirname(__FILE__).'/SplFileObject_fwrite_variation_001.txt';
> 3 if(file_exists($file)) {
> 4 unlink($file);
> 5 }
> 6 $obj = New SplFileObject($file,'w');
> 7 $obj->fwrite('test_write',4);
> 8 var_dump(file_get_contents($file));
> 9 if(file_exists($file)) {
> 10 unlink($file);
> 11 }
> 12 ?>
>
>
> considering 2 alternative ways to solve the problem (both make the test
> pass):
> 1) remove lines 9-11 - as these tests unlink anyhow on lines 3-5
> 2) unset($obj) before the second removal
>
> What do you consider the best approach here?
As a good practice there should be an ---CLEANUP-- (?) section to do the
house keeping even if the script fails for some reason. In this case I'd
move lines 9-11 into CLEANUP.
johannes