Skip to content

Commit

Permalink
fixed broken plugin system
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Sarnowski committed Apr 18, 2012
1 parent f9b8008 commit 32f9c18
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 24 deletions.
21 changes: 21 additions & 0 deletions _testing/core/DokuWikiTest.php
Expand Up @@ -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
*
Expand Down Expand Up @@ -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();
Expand Down
31 changes: 7 additions & 24 deletions _testing/tests/testing/inttests_plugins.test.php
Expand Up @@ -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();
Expand All @@ -44,6 +27,6 @@ function() use (&$hookTriggered) {

$request->execute();

$this->assertFalse($hookTriggered, 'Testing plugin did trigger!');
}
$this->assertTrue($hookTriggered, 'Testing plugin did not trigger!');
}
}
24 changes: 24 additions & 0 deletions _testing/tests/testing/inttests_plugins_default.test.php
@@ -0,0 +1,24 @@
<?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 comments on commit 32f9c18

Please sign in to comment.