diff options
Diffstat (limited to '_testing/tests/testing')
-rw-r--r-- | _testing/tests/testing/inttests_basic.test.php | 22 | ||||
-rw-r--r-- | _testing/tests/testing/inttests_globals.test.php | 22 | ||||
-rw-r--r-- | _testing/tests/testing/inttests_hooks.test.php | 20 | ||||
-rw-r--r-- | _testing/tests/testing/inttests_scope.test.php | 49 |
4 files changed, 113 insertions, 0 deletions
diff --git a/_testing/tests/testing/inttests_basic.test.php b/_testing/tests/testing/inttests_basic.test.php new file mode 100644 index 000000000..ff4b2d5c1 --- /dev/null +++ b/_testing/tests/testing/inttests_basic.test.php @@ -0,0 +1,22 @@ +<?php + +/** + * @group integration + */ +class InttestsBasicTest extends PHPUnit_Framework_TestCase { + /** + * 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/_testing/tests/testing/inttests_globals.test.php b/_testing/tests/testing/inttests_globals.test.php new file mode 100644 index 000000000..40237d704 --- /dev/null +++ b/_testing/tests/testing/inttests_globals.test.php @@ -0,0 +1,22 @@ +<?php + +/** + * @group integration + */ +class InttestsGlobalsTest extends PHPUnit_Framework_TestCase { + /** + * Global variables should be restored for every test case. + */ + function testFirstRun() { + $this->assertEquals('173.194.69.138', $_SERVER['REMOTE_ADDR'], 'Global var not set as expected'); + + $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; + } + + /** + * @depends testFirstRun + */ + function testSecondRun() { + $this->assertEquals('173.194.69.138', $_SERVER['REMOTE_ADDR'], 'Global var not set as expected'); + } +} diff --git a/_testing/tests/testing/inttests_hooks.test.php b/_testing/tests/testing/inttests_hooks.test.php new file mode 100644 index 000000000..d3fdbd738 --- /dev/null +++ b/_testing/tests/testing/inttests_hooks.test.php @@ -0,0 +1,20 @@ +<?php + +/** + * @group integration + */ +class InttestsHooksTest extends PHPUnit_Framework_TestCase { + + function testHookTriggering() { + $request = new TestRequest(); + + $hookTriggered = false; + $request->hook('TPL_CONTENT_DISPLAY', 'AFTER', function() use (&$hookTriggered) { + $hookTriggered = true; + }); + + $request->execute(); + + $this->assertTrue($hookTriggered, 'Hook was not triggered as expected!'); + } +} diff --git a/_testing/tests/testing/inttests_scope.test.php b/_testing/tests/testing/inttests_scope.test.php new file mode 100644 index 000000000..80c1fbd4e --- /dev/null +++ b/_testing/tests/testing/inttests_scope.test.php @@ -0,0 +1,49 @@ +<?php + +/** + * @group integration + */ +class InttestsScopeTest extends PHPUnit_Framework_TestCase { + /** + * 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' + ); + } +} |