Skip to content
Snippets Groups Projects
Commit 32f9c184 authored by Tobias Sarnowski's avatar Tobias Sarnowski
Browse files

fixed broken plugin system

parent f9b8008a
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,12 @@
* Helper class to provide basic functionality for tests
*/
abstract class DokuWikiTest extends PHPUnit_Framework_TestCase {
// tests can override this
protected $pluginsEnabled = array();
// tests can override this
protected $pluginsDisabled = array();
/**
* Reset the DokuWiki environment before each test run
*
......@@ -51,6 +57,21 @@ abstract class DokuWikiTest extends PHPUnit_Framework_TestCase {
}
}
// disable and enable configured plugins
foreach ($this->pluginsDisabled as $plugin) {
if (!$plugin_controller->disable($plugin)) {
throw new Exception('Could not disable plugin "'.$plugin.'"!');
}
}
foreach ($this->pluginsEnabled as $plugin) {
/* enable() returns false but works...
if (!$plugin_controller->enable($plugin)) {
throw new Exception('Could not enable plugin "'.$plugin.'"!');
}
*/
$plugin_controller->enable($plugin);
}
// reset event handler
global $EVENT_HANDLER;
$EVENT_HANDLER = new Doku_Event_Handler();
......
......@@ -5,32 +5,15 @@
*/
class InttestsPluginsTest extends DokuWikiTest {
function testTestingPluginEnabled() {
global $EVENT_HANDLER, $plugin_controller;
$this->assertTrue(
$plugin_controller->enable('testing'),
'Could not enable testing plugin.'
function setUp() {
$this->pluginsEnabled = array(
'testing'
);
$request = new TestRequest();
$hookTriggered = false;
$EVENT_HANDLER->register_hook('TESTING_PLUGIN_INSTALLED', 'AFTER', null,
function() use (&$hookTriggered) {
$hookTriggered = true;
}
);
$request->execute();
$this->assertTrue($hookTriggered, 'Testing plugin did not trigger!');
parent::setUp();
}
/**
* @depends testTestingPluginEnabled
*/
function testTestingPluginDisabledDefault() {
function testTestingPluginEnabled() {
global $EVENT_HANDLER;
$request = new TestRequest();
......@@ -44,6 +27,6 @@ class InttestsPluginsTest extends DokuWikiTest {
$request->execute();
$this->assertFalse($hookTriggered, 'Testing plugin did trigger!');
}
$this->assertTrue($hookTriggered, 'Testing plugin did not trigger!');
}
}
<?php
/**
* @group integration
*/
class InttestsPluginsDefaultTest extends DokuWikiTest {
function testTestingPluginDisabledDefault() {
global $EVENT_HANDLER;
$request = new TestRequest();
$hookTriggered = false;
$EVENT_HANDLER->register_hook('TESTING_PLUGIN_INSTALLED', 'AFTER', null,
function() use (&$hookTriggered) {
$hookTriggered = true;
}
);
$request->execute();
$this->assertFalse($hookTriggered, 'Testing plugin did trigger!');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment