From 1101eda89fdb3b8cc5f5fe0dc2c2ac4c1705508e Mon Sep 17 00:00:00 2001 From: Tobias Sarnowski Date: Mon, 16 Apr 2012 14:42:18 +0000 Subject: added scope tests verify that multiple requests can be made with multiple test methods. --- _testing/inttests.php | 13 +++++++++ _testing/inttests/basic.test.php | 14 ---------- _testing/inttests/hooks.test.php | 17 ------------ _testing/inttests/inttests_basic.test.php | 19 +++++++++++++ _testing/inttests/inttests_hooks.test.php | 17 ++++++++++++ _testing/inttests/inttests_scope.test.php | 46 +++++++++++++++++++++++++++++++ 6 files changed, 95 insertions(+), 31 deletions(-) delete mode 100644 _testing/inttests/basic.test.php delete mode 100644 _testing/inttests/hooks.test.php create mode 100644 _testing/inttests/inttests_basic.test.php create mode 100644 _testing/inttests/inttests_hooks.test.php create mode 100644 _testing/inttests/inttests_scope.test.php (limited to '_testing') diff --git a/_testing/inttests.php b/_testing/inttests.php index 7b263deb9..4eb1f0286 100644 --- a/_testing/inttests.php +++ b/_testing/inttests.php @@ -41,6 +41,17 @@ mkdir(DOKU_PLUGIN); rcopy(TMP_DIR, dirname(__FILE__).'/inttests.conf'); rcopy(TMP_DIR, dirname(__FILE__).'/inttests.data'); +// cleanup dir after exit +register_shutdown_function(function() { + // TODO delete recursive tmp dir +}); + +// TODO disable all non-default plugins in config +// TODO if plugin test, enable plugin +// TODO load plugin descriptor and enable dependent plugins + +// TODO set global variables, phpunit will restore them for every test (test that) + // load dw require_once(DOKU_INC.'inc/init.php'); @@ -142,4 +153,6 @@ class TestResponse { function getHeaders() { return $this->headers; } + + // TODO provide findById, findBy... (https://github.com/cosmocode/dokuwiki-plugin-scrape/blob/master/phpQuery-onefile.php) } diff --git a/_testing/inttests/basic.test.php b/_testing/inttests/basic.test.php deleted file mode 100644 index 56cef965f..000000000 --- a/_testing/inttests/basic.test.php +++ /dev/null @@ -1,14 +0,0 @@ -execute(); - - $this->assertTrue( - strpos($response->getContent(), 'DokuWiki') >= 0, - 'DokuWiki was not a word in the output' - ); - } -} diff --git a/_testing/inttests/hooks.test.php b/_testing/inttests/hooks.test.php deleted file mode 100644 index 6a31d5dc2..000000000 --- a/_testing/inttests/hooks.test.php +++ /dev/null @@ -1,17 +0,0 @@ -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/inttests/inttests_basic.test.php b/_testing/inttests/inttests_basic.test.php new file mode 100644 index 000000000..78c333963 --- /dev/null +++ b/_testing/inttests/inttests_basic.test.php @@ -0,0 +1,19 @@ +execute(); + + $this->assertTrue( + strpos($response->getContent(), 'DokuWiki') >= 0, + 'DokuWiki was not a word in the output' + ); + } +} diff --git a/_testing/inttests/inttests_hooks.test.php b/_testing/inttests/inttests_hooks.test.php new file mode 100644 index 000000000..6a31d5dc2 --- /dev/null +++ b/_testing/inttests/inttests_hooks.test.php @@ -0,0 +1,17 @@ +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/inttests/inttests_scope.test.php b/_testing/inttests/inttests_scope.test.php new file mode 100644 index 000000000..e17b49fb3 --- /dev/null +++ b/_testing/inttests/inttests_scope.test.php @@ -0,0 +1,46 @@ +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