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 From e37739ccaac4a28aa2176487a637cbdf3d1b85a0 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 20 Apr 2012 22:19:44 +0200 Subject: some cleanup removed unneeded data files, converted tabs to spaces --- _test/tests/test/basic.test.php | 26 +++++----- _test/tests/test/globals.test.php | 6 +-- _test/tests/test/plugins_defaults.test.php | 4 +- _test/tests/test/reset.test.php | 1 - _test/tests/test/scope.test.php | 78 +++++++++++++++--------------- 5 files changed, 57 insertions(+), 58 deletions(-) (limited to '_test/tests/test') diff --git a/_test/tests/test/basic.test.php b/_test/tests/test/basic.test.php index ca788a91d..b4926d2ba 100644 --- a/_test/tests/test/basic.test.php +++ b/_test/tests/test/basic.test.php @@ -4,19 +4,19 @@ * @group integration */ class InttestsBasicTest extends DokuWikiTest { - /** - * Execute the simplest possible request and expect - * a dokuwiki page which obviously has the word "DokuWiki" - * in it somewhere. - */ - function testSimpleRun() { - $request = new TestRequest(); + /** + * Execute the simplest possible request and expect + * a dokuwiki page which obviously has the word "DokuWiki" + * in it somewhere. + */ + function testSimpleRun() { + $request = new TestRequest(); - $response = $request->execute(); + $response = $request->execute(); - $this->assertTrue( - strpos($response->getContent(), 'DokuWiki') >= 0, - 'DokuWiki was not a word in the output' - ); - } + $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 index b45b2bf83..180fd0d0d 100644 --- a/_test/tests/test/globals.test.php +++ b/_test/tests/test/globals.test.php @@ -5,9 +5,9 @@ */ class InttestsGlobalsTest extends DokuWikiTest { - /** + /** * every request should be with its own variables - */ + */ function testFirstRun() { global $EVENT_HANDLER; @@ -24,7 +24,7 @@ class InttestsGlobalsTest extends DokuWikiTest { ); $request->execute(); - } + } /** * @depends testFirstRun diff --git a/_test/tests/test/plugins_defaults.test.php b/_test/tests/test/plugins_defaults.test.php index a96dac931..953960bb7 100644 --- a/_test/tests/test/plugins_defaults.test.php +++ b/_test/tests/test/plugins_defaults.test.php @@ -5,7 +5,7 @@ */ class InttestsPluginsDefaultTest extends DokuWikiTest { - function testTestingPluginDisabledDefault() { + function testTestingPluginDisabledDefault() { global $EVENT_HANDLER; $request = new TestRequest(); @@ -20,5 +20,5 @@ class InttestsPluginsDefaultTest extends DokuWikiTest { $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 index 7c5978543..39c43cd3b 100644 --- a/_test/tests/test/reset.test.php +++ b/_test/tests/test/reset.test.php @@ -35,5 +35,4 @@ class InttestsScopeTest extends DokuWikiTest { $this->assertFalse($this->triggered, 'trigger'); } - } diff --git a/_test/tests/test/scope.test.php b/_test/tests/test/scope.test.php index 9341ecef8..8c4ad9cf8 100644 --- a/_test/tests/test/scope.test.php +++ b/_test/tests/test/scope.test.php @@ -4,46 +4,46 @@ * @group integration */ class InttestsResetTest extends DokuWikiTest { - /** - * It should be possible to have two test cases within one test class. - */ - function testFirstRun() { - $request = new TestRequest(); - $response = $request->execute(); - $this->assertTrue( - strpos($response->getContent(), 'DokuWiki') >= 0, - 'DokuWiki was not a word in the output' - ); - } + /** + * It should be possible to have two test cases within one test class. + */ + function testFirstRun() { + $request = new TestRequest(); + $response = $request->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' - ); - } + /** + * @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' - ); + /** + * 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' - ); - } + $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