diff options
Diffstat (limited to '_test/tests/test')
-rw-r--r-- | _test/tests/test/basic.test.php | 22 | ||||
-rw-r--r-- | _test/tests/test/globals.test.php | 49 | ||||
-rw-r--r-- | _test/tests/test/hooks.test.php | 24 | ||||
-rw-r--r-- | _test/tests/test/phpquery.test.php | 18 | ||||
-rw-r--r-- | _test/tests/test/plugins.test.php | 32 | ||||
-rw-r--r-- | _test/tests/test/plugins_defaults.test.php | 24 | ||||
-rw-r--r-- | _test/tests/test/reset.test.php | 38 | ||||
-rw-r--r-- | _test/tests/test/scope.test.php | 49 |
8 files changed, 256 insertions, 0 deletions
diff --git a/_test/tests/test/basic.test.php b/_test/tests/test/basic.test.php new file mode 100644 index 000000000..b4926d2ba --- /dev/null +++ b/_test/tests/test/basic.test.php @@ -0,0 +1,22 @@ +<?php + +/** + * @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(); + + $response = $request->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..180fd0d0d --- /dev/null +++ b/_test/tests/test/globals.test.php @@ -0,0 +1,49 @@ +<?php + +/** + * @group integration + */ +class InttestsGlobalsTest extends DokuWikiTest { + + /** + * every request should be with its own variables + */ + function testFirstRun() { + global $EVENT_HANDLER; + + $request = new TestRequest(); + $request->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 @@ +<?php + +/** + * @group integration + */ +class InttestsHooksTest extends DokuWikiTest { + + function testHookTriggering() { + global $EVENT_HANDLER; + + $request = new TestRequest(); + $hookTriggered = false; + + $EVENT_HANDLER->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 @@ +<?php + +/** + * @group integration + */ +class InttestsPHPQueryTest extends DokuWikiTest { + /** + * Execute the simplest possible request and check the + * meta generator tag is set to "DokuWiki" + */ + function testSimpleRun() { + $request = new TestRequest(); + + $response = $request->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 @@ +<?php + +/** + * @group integration + */ +class InttestsPluginsTest extends DokuWikiTest { + + function setUp() { + $this->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..953960bb7 --- /dev/null +++ b/_test/tests/test/plugins_defaults.test.php @@ -0,0 +1,24 @@ +<?php + +/** + * @group integration + */ +class InttestsPluginsDefaultTest extends DokuWikiTest { + + 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!'); + } +} diff --git a/_test/tests/test/reset.test.php b/_test/tests/test/reset.test.php new file mode 100644 index 000000000..39c43cd3b --- /dev/null +++ b/_test/tests/test/reset.test.php @@ -0,0 +1,38 @@ +<?php + +/** + * @group integration + */ +class InttestsScopeTest extends DokuWikiTest { + + public $triggered = false; + + function testFirstRun(){ + global $conf; + $conf['foo'] = 'bar'; + + global $EVENT_HANDLER; + $self = $this; + $EVENT_HANDLER->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..8c4ad9cf8 --- /dev/null +++ b/_test/tests/test/scope.test.php @@ -0,0 +1,49 @@ +<?php + +/** + * @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' + ); + } + + /** + * @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' + ); + } +} |