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/testing/inttests_globals.test.php | |
parent | e048653b52aad13b5964e1626192ffee2211870b (diff) | |
download | rpg-f9b8008a4ccae56009894e4052dba80752d562bc.tar.gz rpg-f9b8008a4ccae56009894e4052dba80752d562bc.tar.bz2 |
BROKEN added enable/disable feature for plugins
Diffstat (limited to '_testing/tests/testing/inttests_globals.test.php')
-rw-r--r-- | _testing/tests/testing/inttests_globals.test.php | 47 |
1 files changed, 37 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(); + } } |