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/core/TestRequest.php | 82 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 _test/core/TestRequest.php (limited to '_test/core/TestRequest.php') diff --git a/_test/core/TestRequest.php b/_test/core/TestRequest.php new file mode 100644 index 000000000..fa3ddec90 --- /dev/null +++ b/_test/core/TestRequest.php @@ -0,0 +1,82 @@ +server[$key]; } + public function getSession($key) { return $this->session[$key]; } + public function getGet($key) { return $this->get[$key]; } + public function getPost($key) { return $this->post[$key]; } + + public function setServer($key, $value) { $this->server[$key] = $value; } + public function setSession($key, $value) { $this->session[$key] = $value; } + public function setGet($key, $value) { $this->get[$key] = $value; } + public function setPost($key, $value) { $this->post[$key] = $value; } + + /** + * Executes the request + * + * @return TestResponse the resulting output of the request + */ + public function execute() { + // save old environment + $server = $_SERVER; + $session = $_SESSION; + $get = $_GET; + $post = $_POST; + $request = $_REQUEST; + + // fake environment + global $default_server_vars; + $_SERVER = array_merge($default_server_vars, $this->server); + $_SESSION = $this->session; + $_GET = $this->get; + $_POST = $this->post; + $_REQUEST = array_merge($_GET, $_POST); + + // reset output buffer + global $output_buffer; + $output_buffer = ''; + + // now execute dokuwiki and grep the output + header_remove(); + ob_start('ob_start_callback'); + include(DOKU_INC.'doku.php'); + ob_end_flush(); + + // create the response object + $response = new TestResponse( + $output_buffer, + headers_list() + ); + + // reset environment + $_SERVER = $server; + $_SESSION = $session; + $_GET = $get; + $_POST = $post; + $_REQUEST = $request; + + return $response; + } +} -- cgit v1.2.3 From fbb9105e038726f81bd25f31893ef38fe7f06530 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 25 Jun 2012 14:30:16 +0200 Subject: fixed tests The test suite was missing a global keyword to access the $INPUT class. --- _test/core/TestRequest.php | 3 +++ 1 file changed, 3 insertions(+) (limited to '_test/core/TestRequest.php') diff --git a/_test/core/TestRequest.php b/_test/core/TestRequest.php index fa3ddec90..9047f7e88 100644 --- a/_test/core/TestRequest.php +++ b/_test/core/TestRequest.php @@ -58,6 +58,9 @@ class TestRequest { global $output_buffer; $output_buffer = ''; + // make globals available as were in a function context here FIXME: any others needed? + global $INPUT; + // now execute dokuwiki and grep the output header_remove(); ob_start('ob_start_callback'); -- cgit v1.2.3 From 0189bd8669742c5290a4f6538f954b81554e26d2 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 28 Jun 2012 16:43:01 +0200 Subject: make sure all globals are available in test requests --- _test/core/TestRequest.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to '_test/core/TestRequest.php') diff --git a/_test/core/TestRequest.php b/_test/core/TestRequest.php index 9047f7e88..66760b1e0 100644 --- a/_test/core/TestRequest.php +++ b/_test/core/TestRequest.php @@ -46,6 +46,11 @@ class TestRequest { $post = $_POST; $request = $_REQUEST; + // import all defined globals into the function scope + foreach(array_keys($GLOBALS) as $glb){ + global $$glb; + } + // fake environment global $default_server_vars; $_SERVER = array_merge($default_server_vars, $this->server); @@ -58,9 +63,6 @@ class TestRequest { global $output_buffer; $output_buffer = ''; - // make globals available as were in a function context here FIXME: any others needed? - global $INPUT; - // now execute dokuwiki and grep the output header_remove(); ob_start('ob_start_callback'); -- cgit v1.2.3