Skip to content

Commit

Permalink
Make zip oo_addpattern test more robust
Browse files Browse the repository at this point in the history
Use a separate directory for the tests, so that no other tests can
concurrently create files in the same directory.
  • Loading branch information
nikic committed Feb 20, 2019
1 parent a92db42 commit 991ea9c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ext/zip/tests/oo_addpattern.phpt
Expand Up @@ -10,11 +10,13 @@ if(!extension_loaded('zip')) die('skip');
?>
--FILE--
<?php
$dirname = dirname(__FILE__) . '/';
include $dirname . 'utils.inc';
$file = $dirname . '__tmp_oo_addpattern.zip';
include __DIR__ . '/utils.inc';

copy($dirname . 'test.zip', $file);
$dirname = __DIR__ . '/oo_addpattern_dir/';
$file = $dirname . 'tmp.zip';

@mkdir($dirname);
copy(__DIR__ . '/test.zip', $file);
touch($dirname . 'foo.txt');
touch($dirname . 'bar.txt');

Expand All @@ -36,10 +38,11 @@ if ($zip->status == ZIPARCHIVE::ER_OK) {
?>
--CLEAN--
<?php
$dirname = dirname(__FILE__) . '/';
unlink($dirname . '__tmp_oo_addpattern.zip');
$dirname = dirname(__FILE__) . '/oo_addpattern_dir/';
unlink($dirname . 'tmp.zip');
unlink($dirname . 'foo.txt');
unlink($dirname . 'bar.txt');
rmdir($dirname);
?>
--EXPECT--
0 bar
Expand Down

0 comments on commit 991ea9c

Please sign in to comment.