aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_framework/phpbb_test_case_helpers.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_framework/phpbb_test_case_helpers.php')
-rw-r--r--tests/test_framework/phpbb_test_case_helpers.php44
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 = '';