diff --git a/_testing/core/DokuWikiTest.php b/_testing/core/DokuWikiTest.php index 2517e25e31..f464aab8e6 100644 --- a/_testing/core/DokuWikiTest.php +++ b/_testing/core/DokuWikiTest.php @@ -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 @@ function setUp() { } } + // 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(); diff --git a/_testing/tests/testing/inttests_plugins.test.php b/_testing/tests/testing/inttests_plugins.test.php index bf3775b267..ac6d1ee45a 100644 --- a/_testing/tests/testing/inttests_plugins.test.php +++ b/_testing/tests/testing/inttests_plugins.test.php @@ -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 @@ function() use (&$hookTriggered) { $request->execute(); - $this->assertFalse($hookTriggered, 'Testing plugin did trigger!'); - } + $this->assertTrue($hookTriggered, 'Testing plugin did not trigger!'); + } } diff --git a/_testing/tests/testing/inttests_plugins_default.test.php b/_testing/tests/testing/inttests_plugins_default.test.php new file mode 100644 index 0000000000..a96dac9319 --- /dev/null +++ b/_testing/tests/testing/inttests_plugins_default.test.php @@ -0,0 +1,24 @@ +register_hook('TESTING_PLUGIN_INSTALLED', 'AFTER', null, + function() use (&$hookTriggered) { + $hookTriggered = true; + } + ); + + $request->execute(); + + $this->assertFalse($hookTriggered, 'Testing plugin did trigger!'); + } +}