summaryrefslogtreecommitdiff
path: root/_testing/core/DokuWikiTest.php
diff options
context:
space:
mode:
authorAndreas Gohr <gohr@cosmocode.de>2012-04-17 15:38:03 +0200
committerAndreas Gohr <gohr@cosmocode.de>2012-04-17 15:38:03 +0200
commite048653b52aad13b5964e1626192ffee2211870b (patch)
treed5aaa7168f1496aa8262920ad2320a5d3668b6a5 /_testing/core/DokuWikiTest.php
parentc45ce44912e3e54ecdf0a19af2d7df1960aa2962 (diff)
downloadrpg-e048653b52aad13b5964e1626192ffee2211870b.tar.gz
rpg-e048653b52aad13b5964e1626192ffee2211870b.tar.bz2
moved functions and classes out of bootstrap
There's still more that I'd like to moved out. bootstrap should not contain any logic but only call the appropriate functions for setup the test environment.
Diffstat (limited to '_testing/core/DokuWikiTest.php')
-rw-r--r--_testing/core/DokuWikiTest.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/_testing/core/DokuWikiTest.php b/_testing/core/DokuWikiTest.php
new file mode 100644
index 000000000..8ae261a52
--- /dev/null
+++ b/_testing/core/DokuWikiTest.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Helper class to provide basic functionality for tests
+ */
+abstract class DokuWikiTest extends PHPUnit_Framework_TestCase {
+ /**
+ * Reset the DokuWiki environment before each test run
+ *
+ * Makes sure loaded config, language and plugins are correct
+ */
+ function setUp() {
+ // reload config
+ global $conf, $config_cascade;
+ $conf = array();
+ foreach (array('default','local','protected') as $config_group) {
+ if (empty($config_cascade['main'][$config_group])) continue;
+ foreach ($config_cascade['main'][$config_group] as $config_file) {
+ if (@file_exists($config_file)) {
+ include($config_file);
+ }
+ }
+ }
+
+ // reload license config
+ global $license;
+ $license = array();
+
+ // load the license file(s)
+ foreach (array('default','local') as $config_group) {
+ if (empty($config_cascade['license'][$config_group])) continue;
+ foreach ($config_cascade['license'][$config_group] as $config_file) {
+ if(@file_exists($config_file)){
+ include($config_file);
+ }
+ }
+ }
+
+ // make real paths and check them
+ init_paths();
+ init_files();
+
+ // reset loaded plugins
+ global $plugin_controller_class, $plugin_controller;
+ $plugin_controller = new $plugin_controller_class();
+ global $EVENT_HANDLER;
+ $EVENT_HANDLER = new Doku_Event_Handler();
+
+ // reload language
+ $local = $conf['lang'];
+ trigger_event('INIT_LANG_LOAD', $local, 'init_lang', true);
+ }
+}