From f2bbbdaaface8ca63a3a70e98140c0e51c5e8b0b Mon Sep 17 00:00:00 2001 From: Fyorl Date: Mon, 2 Jul 2012 22:36:12 +0100 Subject: [PATCH] [ticket/10941] tearDown() now uses explicit file list Instances of $it also renamed for clarity. PHPBB3-10941 --- tests/uploads/filespec_test.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tests/uploads/filespec_test.php b/tests/uploads/filespec_test.php index 3c9eda4468..80237d7622 100644 --- a/tests/uploads/filespec_test.php +++ b/tests/uploads/filespec_test.php @@ -43,8 +43,8 @@ class phpbb_filespec_test extends phpbb_test_case $this->init_filespec(); // Create copies of the files for use in testing move_file - $it = new DirectoryIterator($this->path); - foreach ($it as $fileinfo) + $iterator = new DirectoryIterator($this->path); + foreach ($iterator as $fileinfo) { if ($fileinfo->isDot()) { @@ -142,10 +142,24 @@ class phpbb_filespec_test extends phpbb_test_case protected function tearDown() { - $it = new DirectoryIterator($this->path); - foreach ($it as $fileinfo) + $files = array( + 'gif_copy' => 1, + 'jpg_copy' => 1, + 'png_copy' => 1, + 'txt_copy' => 1, + 'txt_copy_2' => 1, + 'tif_copy' => 1, + 'gif_moved' => 1, + 'jpg_moved' => 1, + 'png_moved' => 1, + 'txt_as_img' => 1, + 'txt_moved' => 1, + ); + + $iterator = new DirectoryIterator($this->path); + foreach ($iterator as $fileinfo) { - if (strlen($fileinfo->getFilename()) > 3) + if (isset($files[$fileinfo->getFilename()])) { unlink($fileinfo->getPathname()); }