Skip to content
Snippets Groups Projects
Commit 4d053d04 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

moved URI setup to execute()

parent 9e777cee
No related branches found
No related tags found
No related merge requests found
...@@ -36,9 +36,10 @@ class TestRequest { ...@@ -36,9 +36,10 @@ class TestRequest {
/** /**
* Executes the request * Executes the request
* *
* @param string $url end URL to simulate, needs to start with /doku.php currently
* @return TestResponse the resulting output of the request * @return TestResponse the resulting output of the request
*/ */
public function execute() { public function execute($uri='/doku.php') {
// save old environment // save old environment
$server = $_SERVER; $server = $_SERVER;
$session = $_SESSION; $session = $_SESSION;
...@@ -46,6 +47,9 @@ class TestRequest { ...@@ -46,6 +47,9 @@ class TestRequest {
$post = $_POST; $post = $_POST;
$request = $_REQUEST; $request = $_REQUEST;
// prepare the right URI
$this->setUri($uri);
// import all defined globals into the function scope // import all defined globals into the function scope
foreach(array_keys($GLOBALS) as $glb){ foreach(array_keys($GLOBALS) as $glb){
global $$glb; global $$glb;
...@@ -95,8 +99,9 @@ class TestRequest { ...@@ -95,8 +99,9 @@ class TestRequest {
* with all set GET variables. * with all set GET variables.
* *
* @param string $url end URL to simulate, needs to start with /doku.php currently * @param string $url end URL to simulate, needs to start with /doku.php currently
* @todo make this work with other end points
*/ */
public function setUri($uri){ protected function setUri($uri){
if(substr($uri,0,9) != '/doku.php'){ if(substr($uri,0,9) != '/doku.php'){
throw new Exception("only '/doku.php' is supported currently"); throw new Exception("only '/doku.php' is supported currently");
} }
...@@ -128,10 +133,9 @@ class TestRequest { ...@@ -128,10 +133,9 @@ class TestRequest {
* @param return TestResponse * @param return TestResponse
*/ */
public function post($post=array(), $uri='/doku.php') { public function post($post=array(), $uri='/doku.php') {
$this->setUri($uri);
$this->post = array_merge($this->post, $post); $this->post = array_merge($this->post, $post);
$this->setServer('REQUEST_METHOD', 'POST'); $this->setServer('REQUEST_METHOD', 'POST');
return $this->execute(); return $this->execute($uri);
} }
/** /**
...@@ -143,9 +147,8 @@ class TestRequest { ...@@ -143,9 +147,8 @@ class TestRequest {
*/ */
public function get($get=array(), $uri='/doku.php') { public function get($get=array(), $uri='/doku.php') {
$this->get = array_merge($this->get, $get); $this->get = array_merge($this->get, $get);
$this->setUri($uri);
$this->setServer('REQUEST_METHOD', 'GET'); $this->setServer('REQUEST_METHOD', 'GET');
return $this->execute(); return $this->execute($uri);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment