diff options
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(); + } } |