From f8369d7d6e37248d6523fdac6e1d760fca4f1b52 Mon Sep 17 00:00:00 2001 From: Tobias Sarnowski Date: Wed, 18 Apr 2012 12:08:28 +0200 Subject: moved _testing to _test --- _test/tests/test/basic.test.php | 22 ++++++++++++++ _test/tests/test/globals.test.php | 49 ++++++++++++++++++++++++++++++ _test/tests/test/hooks.test.php | 24 +++++++++++++++ _test/tests/test/phpquery.test.php | 18 +++++++++++ _test/tests/test/plugins.test.php | 32 +++++++++++++++++++ _test/tests/test/plugins_defaults.test.php | 24 +++++++++++++++ _test/tests/test/reset.test.php | 39 ++++++++++++++++++++++++ _test/tests/test/scope.test.php | 49 ++++++++++++++++++++++++++++++ 8 files changed, 257 insertions(+) create mode 100644 _test/tests/test/basic.test.php create mode 100644 _test/tests/test/globals.test.php create mode 100644 _test/tests/test/hooks.test.php create mode 100644 _test/tests/test/phpquery.test.php create mode 100644 _test/tests/test/plugins.test.php create mode 100644 _test/tests/test/plugins_defaults.test.php create mode 100644 _test/tests/test/reset.test.php create mode 100644 _test/tests/test/scope.test.php (limited to '_test/tests/test') diff --git a/_test/tests/test/basic.test.php b/_test/tests/test/basic.test.php new file mode 100644 index 000000000..ca788a91d --- /dev/null +++ b/_test/tests/test/basic.test.php @@ -0,0 +1,22 @@ +execute(); + + $this->assertTrue( + strpos($response->getContent(), 'DokuWiki') >= 0, + 'DokuWiki was not a word in the output' + ); + } +} diff --git a/_test/tests/test/globals.test.php b/_test/tests/test/globals.test.php new file mode 100644 index 000000000..b45b2bf83 --- /dev/null +++ b/_test/tests/test/globals.test.php @@ -0,0 +1,49 @@ +setServer('testvar', true); + + $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/_test/tests/test/hooks.test.php b/_test/tests/test/hooks.test.php new file mode 100644 index 000000000..621b9f9b8 --- /dev/null +++ b/_test/tests/test/hooks.test.php @@ -0,0 +1,24 @@ +register_hook('TPL_CONTENT_DISPLAY', 'AFTER', null, + function() use (&$hookTriggered) { + $hookTriggered = true; + } + ); + + $request->execute(); + + $this->assertTrue($hookTriggered, 'Hook was not triggered as expected!'); + } +} diff --git a/_test/tests/test/phpquery.test.php b/_test/tests/test/phpquery.test.php new file mode 100644 index 000000000..188d834cb --- /dev/null +++ b/_test/tests/test/phpquery.test.php @@ -0,0 +1,18 @@ +execute(); + + $this->assertEquals('DokuWiki', $response->queryHTML('meta[name="generator"]')->attr('content') ); + } +} diff --git a/_test/tests/test/plugins.test.php b/_test/tests/test/plugins.test.php new file mode 100644 index 000000000..ac6d1ee45 --- /dev/null +++ b/_test/tests/test/plugins.test.php @@ -0,0 +1,32 @@ +pluginsEnabled = array( + 'testing' + ); + + parent::setUp(); + } + + function testTestingPluginEnabled() { + 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->assertTrue($hookTriggered, 'Testing plugin did not trigger!'); + } +} diff --git a/_test/tests/test/plugins_defaults.test.php b/_test/tests/test/plugins_defaults.test.php new file mode 100644 index 000000000..a96dac931 --- /dev/null +++ b/_test/tests/test/plugins_defaults.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!'); + } +} diff --git a/_test/tests/test/reset.test.php b/_test/tests/test/reset.test.php new file mode 100644 index 000000000..7c5978543 --- /dev/null +++ b/_test/tests/test/reset.test.php @@ -0,0 +1,39 @@ +register_hook('DOKUWIKI_STARTED', 'AFTER', null, + function() use ($self) { + $self->triggered = true; + } + ); + $request = new TestRequest(); + $request->execute(); + $this->assertTrue($this->triggered); + } + + /** + * @depends testFirstRun + */ + function testSecondRun(){ + global $conf; + $this->assertFalse(isset($conf['foo']), 'conf setting'); + + $request = new TestRequest(); + $request->execute(); + + $this->assertFalse($this->triggered, 'trigger'); + } + +} diff --git a/_test/tests/test/scope.test.php b/_test/tests/test/scope.test.php new file mode 100644 index 000000000..9341ecef8 --- /dev/null +++ b/_test/tests/test/scope.test.php @@ -0,0 +1,49 @@ +execute(); + $this->assertTrue( + strpos($response->getContent(), 'DokuWiki') >= 0, + 'DokuWiki was not a word in the output' + ); + } + + /** + * @depends testFirstRun + */ + function testSecondRun() { + $request = new TestRequest(); + $response = $request->execute(); + $this->assertTrue( + strpos($response->getContent(), 'DokuWiki') >= 0, + 'DokuWiki was not a word in the output' + ); + } + + /** + * two requests within the same test case should be possible + */ + function testMultipleRequests() { + $request = new TestRequest(); + $response = $request->execute(); + $this->assertTrue( + strpos($response->getContent(), 'DokuWiki') >= 0, + 'DokuWiki was not a word in the output' + ); + + $request = new TestRequest(); + $response = $request->execute(); + $this->assertTrue( + strpos($response->getContent(), 'DokuWiki') >= 0, + 'DokuWiki was not a word in the output' + ); + } +} -- cgit v1.2.3