summaryrefslogtreecommitdiff
path: root/_test/index.php
diff options
context:
space:
mode:
authorMichael Klier <chi@chimeric.de>2010-03-30 11:15:08 +0200
committerMichael Klier <chi@chimeric.de>2010-03-30 11:15:08 +0200
commit08d7babffe1bded4620d0a3624bdd80522283138 (patch)
tree0e5368bff1ab25457cd9b1150ac1d1fc2f2fea92 /_test/index.php
parent2a98590b375e0acfd24fb0da343eb09a3ff76ff3 (diff)
downloadrpg-08d7babffe1bded4620d0a3624bdd80522283138.tar.gz
rpg-08d7babffe1bded4620d0a3624bdd80522283138.tar.bz2
added support for plugin unittests
This patch adds support to include plugin tests in the DokuWiki testsuite. Plugin tests are located in a dedicated directory _test/within a plugin directory. The naming convention of the test files follows the one used in DokuWikis testsuite. <plugin>/_test/*.test.php -> single test <plugin>/_test/*.group.php -> group test The plugin tests are accessible via the web interface of the test suite and via the cli interface. It is recommend to bundle plugin test in a plugin group test. The webinterface also allows to run all plugin tests at once. Test files must include: <dokuwiki>/_test/lib/unittest.php Example Test: require_once(DOKU_INC.'_test/lib/unittest.php'); class plugin_test extends Doku_UnitTestCase { function test() { $this->assertEqual(1,1); } } Example Group Test: require_once(DOKU_INC.'_test/lib/unittest.php'); class plugin_group_test extends Doku_GroupTest { function group_test() { $dir = dirname(__FILE__).'/'; $this->GroupTest('plugin_grouptest'); $this->addTestFile($dir . 'plugin.test1.php'); $this->addTestFile($dir . 'plugin.test2.php'); $this->addTestFile($dir . 'plugin.test3.php'); } } At the moment unittest.php contains only two meta classes so plugins tests don't have to inherit from the simpletest classes. This patch should be treated as intermediate step to allow for plugin tests. The testsuite wasn't designed to include plugin tests. It should probably be refactored at a later point.
Diffstat (limited to '_test/index.php')
-rw-r--r--_test/index.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/_test/index.php b/_test/index.php
index 87cc10a35..f59c44cf4 100644
--- a/_test/index.php
+++ b/_test/index.php
@@ -130,6 +130,30 @@ function DW_TESTS_PaintGroupTestList() {
}
}
+function DW_TESTS_PaintPluginTestCaseList() {
+ switch ( DW_TESTS_OUTPUT ) {
+ case DW_TESTS_OUTPUT_XML:
+ echo XMLTestManager::getPluginTestCaseList(TEST_PLUGINS);
+ break;
+ case DW_TESTS_OUTPUT_HTML:
+ default:
+ echo HTMLTestManager::getPluginTestCaseList(TEST_PLUGINS);
+ break;
+ }
+}
+
+function DW_TESTS_PaintPluginGroupTestList() {
+ switch ( DW_TESTS_OUTPUT ) {
+ case DW_TESTS_OUTPUT_XML:
+ echo XMLTestManager::getPluginGroupTestList(TEST_PLUGINS);
+ break;
+ case DW_TESTS_OUTPUT_HTML:
+ default:
+ echo HTMLTestManager::getPluginGroupTestList(TEST_PLUGINS);
+ break;
+ }
+}
+
function DW_TESTS_PaintFooter() {
switch ( DW_TESTS_OUTPUT ) {
case DW_TESTS_OUTPUT_XML:
@@ -160,6 +184,19 @@ if (isset($_GET['group'])) {
exit();
}
+// If it's a plugin group test
+if (isset($_GET['plugin_group'])) {
+ if ('all' == $_GET['plugin_group']) {
+ TestManager::runAllPluginTests(DW_TESTS_GetReporter());
+ } else {
+ TestManager::runGroupTest(ucfirst($_GET['plugin_group']),
+ TEST_PLUGINS,
+ DW_TESTS_GetReporter());
+ }
+ DW_TESTS_PaintRunMore();
+ exit();
+}
+
// If it's a single test case
if (isset($_GET['case'])) {
TestManager::runTestCase($_GET['case'], TEST_CASES, DW_TESTS_GetReporter());
@@ -167,6 +204,13 @@ if (isset($_GET['case'])) {
exit();
}
+// If it's a single plugin test case
+if (isset($_GET['plugin_case'])) {
+ TestManager::runTestCase($_GET['plugin_case'], TEST_PLUGINS, DW_TESTS_GetReporter());
+ DW_TESTS_PaintRunMore();
+ exit();
+}
+
// Else it's the main page
DW_TESTS_PaintHeader();
@@ -174,9 +218,11 @@ DW_TESTS_PaintSuiteHeader();
if (isset($_GET['show']) && $_GET['show'] == 'cases') {
DW_TESTS_PaintCaseList();
+ DW_TESTS_PaintPluginTestCaseList();
} else {
/* no group specified, so list them all */
DW_TESTS_PaintGroupTestList();
+ DW_TESTS_PaintPluginGroupTestList();
}
DW_TESTS_PaintFooter();