From c8ee6cb0c200b7e64ebbae11806f4daddfd8d93d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 8 Jun 2013 17:00:27 +0200 Subject: [ticket/11550] Move functionality for copying/restoring to test case helpers PHPBB3-11550 --- tests/test_framework/phpbb_test_case_helpers.php | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'tests/test_framework/phpbb_test_case_helpers.php') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 20ae384f21..0e0b5c2a8f 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -18,6 +18,50 @@ class phpbb_test_case_helpers $this->test_case = $test_case; } + private $copied_files = array(); + + public function copy_ext_fixtures($fixtures_dir, $fixtures) + { + global $phpbb_root_path; + + $this->copied_files = array(); + + if (file_exists($phpbb_root_path . 'ext/')) + { + // First, move any extensions setup on the board to a temp directory + $this->copied_files = $this->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/'); + + // Then empty the ext/ directory on the board (for accurate test cases) + $this->empty_dir($phpbb_root_path . 'ext/'); + } + + // Copy our ext/ files from the test case to the board + foreach ($fixtures as $fixture) + { + $this->copied_files = array_merge($this->copied_files, $this->copy_dir($fixtures_dir . 'ext/' . $fixture, $phpbb_root_path . 'ext/' . $fixture)); + } + } + + public function restore_original_ext_dir() + { + global $phpbb_root_path; + + // Copy back the board installed extensions from the temp directory + if (file_exists($phpbb_root_path . 'store/temp_ext/')) + { + $this->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/'); + } + + // Remove all of the files we copied around (from board ext -> temp_ext, from test ext -> board ext) + $this->remove_files($this->copied_files); + $this->copied_files = array(); + + if (file_exists($phpbb_root_path . 'store/temp_ext/')) + { + $this->empty_dir($phpbb_root_path . 'store/temp_ext/'); + } + } + public function setExpectedTriggerError($errno, $message = '') { $exceptionName = ''; -- cgit v1.2.1 From a61ab1e5e4bbe786d3f500438bb0dd6ca395989e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 8 Jun 2013 17:02:31 +0200 Subject: [ticket/11550] Use new functionality from the test case helpers Instead of duplicating the extension copy code, it is now in the helpers. So we remove the code from existing tests. PHPBB3-11550 --- tests/test_framework/phpbb_test_case_helpers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_test_case_helpers.php') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 0e0b5c2a8f..367bd3b142 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -38,7 +38,7 @@ class phpbb_test_case_helpers // Copy our ext/ files from the test case to the board foreach ($fixtures as $fixture) { - $this->copied_files = array_merge($this->copied_files, $this->copy_dir($fixtures_dir . 'ext/' . $fixture, $phpbb_root_path . 'ext/' . $fixture)); + $this->copied_files = array_merge($this->copied_files, $this->copy_dir($fixtures_dir . $fixture, $phpbb_root_path . 'ext/' . $fixture)); } } -- cgit v1.2.1 From 68d15f0f14dfdc827e1169a73c194a9e30795605 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 11 Jun 2013 11:14:24 +0200 Subject: [ticket/11550] Move comments to correct function PHPBB3-11550 --- tests/test_framework/phpbb_test_case_helpers.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/test_framework/phpbb_test_case_helpers.php') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 367bd3b142..1b08f2368f 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -20,6 +20,10 @@ class phpbb_test_case_helpers private $copied_files = array(); + /** + * This should only be called once before the tests are run. + * This is used to copy the fixtures to the phpBB install + */ public function copy_ext_fixtures($fixtures_dir, $fixtures) { global $phpbb_root_path; @@ -42,6 +46,10 @@ class phpbb_test_case_helpers } } + /** + * This should only be called once after the tests are run. + * This is used to remove the fixtures from the phpBB install + */ public function restore_original_ext_dir() { global $phpbb_root_path; -- cgit v1.2.1 From d02f98c63530454700661fc80354d66207ed8b02 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 11 Jun 2013 16:03:34 +0200 Subject: [ticket/11605] Use empty_dir to better delete files and dirs of extensions PHPBB3-11605 --- tests/test_framework/phpbb_test_case_helpers.php | 29 +++++------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'tests/test_framework/phpbb_test_case_helpers.php') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 1b08f2368f..8c91d357b8 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -54,14 +54,18 @@ class phpbb_test_case_helpers { global $phpbb_root_path; + // Remove all of the files we copied from test ext -> board ext + $this->empty_dir($phpbb_root_path . 'ext/'); + // Copy back the board installed extensions from the temp directory if (file_exists($phpbb_root_path . 'store/temp_ext/')) { $this->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/'); + + // Remove all of the files we copied from board ext -> temp_ext + $this->empty_dir($phpbb_root_path . 'store/temp_ext/'); } - // Remove all of the files we copied around (from board ext -> temp_ext, from test ext -> board ext) - $this->remove_files($this->copied_files); $this->copied_files = array(); if (file_exists($phpbb_root_path . 'store/temp_ext/')) @@ -254,27 +258,6 @@ class phpbb_test_case_helpers return $copied_files; } - /** - * Remove files/directories that are listed in an array - * Designed for use with $this->copy_dir() - * - * @param array $file_list - */ - public function remove_files($file_list) - { - foreach ($file_list as $file) - { - if (is_dir($file)) - { - rmdir($file); - } - else - { - unlink($file); - } - } - } - /** * Empty directory (remove any subdirectories/files below) * -- cgit v1.2.1 From fa8d5c7d209b616e9552e072e38242ef4e74aaca Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 11 Jun 2013 16:04:23 +0200 Subject: [ticket/11605] Remove unused copied_files property PHPBB3-11605 --- tests/test_framework/phpbb_test_case_helpers.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'tests/test_framework/phpbb_test_case_helpers.php') diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 8c91d357b8..50b2bf03ec 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -18,8 +18,6 @@ class phpbb_test_case_helpers $this->test_case = $test_case; } - private $copied_files = array(); - /** * This should only be called once before the tests are run. * This is used to copy the fixtures to the phpBB install @@ -28,12 +26,10 @@ class phpbb_test_case_helpers { global $phpbb_root_path; - $this->copied_files = array(); - if (file_exists($phpbb_root_path . 'ext/')) { // First, move any extensions setup on the board to a temp directory - $this->copied_files = $this->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/'); + $this->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/'); // Then empty the ext/ directory on the board (for accurate test cases) $this->empty_dir($phpbb_root_path . 'ext/'); @@ -42,7 +38,7 @@ class phpbb_test_case_helpers // Copy our ext/ files from the test case to the board foreach ($fixtures as $fixture) { - $this->copied_files = array_merge($this->copied_files, $this->copy_dir($fixtures_dir . $fixture, $phpbb_root_path . 'ext/' . $fixture)); + $this->copy_dir($fixtures_dir . $fixture, $phpbb_root_path . 'ext/' . $fixture); } } @@ -66,8 +62,6 @@ class phpbb_test_case_helpers $this->empty_dir($phpbb_root_path . 'store/temp_ext/'); } - $this->copied_files = array(); - if (file_exists($phpbb_root_path . 'store/temp_ext/')) { $this->empty_dir($phpbb_root_path . 'store/temp_ext/'); -- cgit v1.2.1