diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-06-08 17:00:27 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-06-08 17:03:08 +0200 |
commit | c8ee6cb0c200b7e64ebbae11806f4daddfd8d93d (patch) | |
tree | df74af392437df27df05cf13bd809ad5f0d5b017 /tests/test_framework/phpbb_test_case_helpers.php | |
parent | 35064086377c3f3334e02ca153b008b0502fbdee (diff) | |
download | forums-c8ee6cb0c200b7e64ebbae11806f4daddfd8d93d.tar forums-c8ee6cb0c200b7e64ebbae11806f4daddfd8d93d.tar.gz forums-c8ee6cb0c200b7e64ebbae11806f4daddfd8d93d.tar.bz2 forums-c8ee6cb0c200b7e64ebbae11806f4daddfd8d93d.tar.xz forums-c8ee6cb0c200b7e64ebbae11806f4daddfd8d93d.zip |
[ticket/11550] Move functionality for copying/restoring to test case helpers
PHPBB3-11550
Diffstat (limited to 'tests/test_framework/phpbb_test_case_helpers.php')
-rw-r--r-- | tests/test_framework/phpbb_test_case_helpers.php | 44 |
1 files changed, 44 insertions, 0 deletions
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 = ''; |