diff options
author | Tobias Sarnowski <sarnowski@cosmocode.de> | 2012-04-17 17:27:27 +0200 |
---|---|---|
committer | Tobias Sarnowski <sarnowski@cosmocode.de> | 2012-04-17 17:27:27 +0200 |
commit | f9b8008a4ccae56009894e4052dba80752d562bc (patch) | |
tree | 453331a525fc3e09c30ca3e52d85959306fe41bc /_testing/tests | |
parent | e048653b52aad13b5964e1626192ffee2211870b (diff) | |
download | rpg-f9b8008a4ccae56009894e4052dba80752d562bc.tar.gz rpg-f9b8008a4ccae56009894e4052dba80752d562bc.tar.bz2 |
BROKEN added enable/disable feature for plugins
Diffstat (limited to '_testing/tests')
-rw-r--r-- | _testing/tests/testing/inttests_globals.test.php | 47 | ||||
-rw-r--r-- | _testing/tests/testing/inttests_plugins.test.php | 49 |
2 files changed, 86 insertions, 10 deletions
diff --git a/_testing/tests/testing/inttests_globals.test.php b/_testing/tests/testing/inttests_globals.test.php index d3beb433d..b45b2bf83 100644 --- a/_testing/tests/testing/inttests_globals.test.php +++ b/_testing/tests/testing/inttests_globals.test.php @@ -4,19 +4,46 @@ * @group integration */ class InttestsGlobalsTest extends DokuWikiTest { + /** - * Global variables should be restored for every test case. + * every request should be with its own variables */ - function testFirstRun() { - $this->assertEquals('87.142.120.6', $_SERVER['REMOTE_ADDR'], 'Global var not set as expected'); + function testFirstRun() { + global $EVENT_HANDLER; - $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; - } + $request = new TestRequest(); + $request->setServer('testvar', true); - /** - * @depends testFirstRun - */ - function testSecondRun() { - $this->assertEquals('87.142.120.6', $_SERVER['REMOTE_ADDR'], 'Global var not set as expected'); + $self = $this; + $EVENT_HANDLER->register_hook('TPL_CONTENT_DISPLAY', 'AFTER', null, + function() use ($self) { + $self->assertTrue($_SERVER['testvar'], 'Server variable not set correctly: testvar'); + $self->assertEquals('87.142.120.6', $_SERVER['REMOTE_ADDR'], 'Server variable not set correctly: REMOTE_ADDR'); + $_SERVER['tmpvar'] = true; + } + ); + + $request->execute(); } + + /** + * @depends testFirstRun + */ + function testSecondRun() { + global $EVENT_HANDLER; + + $request = new TestRequest(); + $request->setServer('testvar', false); + + $self = $this; + $EVENT_HANDLER->register_hook('TPL_CONTENT_DISPLAY', 'AFTER', null, + function() use ($self) { + $self->assertFalse($_SERVER['testvar'], 'Server variable not set correctly: testvar'); + $self->assertEquals('87.142.120.6', $_SERVER['REMOTE_ADDR'], 'Server variable not set correctly: REMOTE_ADDR'); + $self->assertFalse(isset($_SERVER['tmpvar'])); + } + ); + + $request->execute(); + } } diff --git a/_testing/tests/testing/inttests_plugins.test.php b/_testing/tests/testing/inttests_plugins.test.php new file mode 100644 index 000000000..bf3775b26 --- /dev/null +++ b/_testing/tests/testing/inttests_plugins.test.php @@ -0,0 +1,49 @@ +<?php + +/** + * @group integration + */ +class InttestsPluginsTest extends DokuWikiTest { + + function testTestingPluginEnabled() { + global $EVENT_HANDLER, $plugin_controller; + + $this->assertTrue( + $plugin_controller->enable('testing'), + 'Could not enable testing plugin.' + ); + + $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!'); + } + + /** + * @depends testTestingPluginEnabled + */ + 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!'); + } +} |