From 4d053d04448a73826574eeb5e6be7e4d53c38ae6 Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Sat, 30 Jun 2012 01:34:21 +0200
Subject: [PATCH] moved URI setup to execute()

---
 _test/core/TestRequest.php | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/_test/core/TestRequest.php b/_test/core/TestRequest.php
index aeda4b892..172821576 100644
--- a/_test/core/TestRequest.php
+++ b/_test/core/TestRequest.php
@@ -36,9 +36,10 @@ class TestRequest {
     /**
      * 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
      */
-    public function execute() {
+    public function execute($uri='/doku.php') {
         // save old environment
         $server = $_SERVER;
         $session = $_SESSION;
@@ -46,6 +47,9 @@ class TestRequest {
         $post = $_POST;
         $request = $_REQUEST;
 
+        // prepare the right URI
+        $this->setUri($uri);
+
         // import all defined globals into the function scope
         foreach(array_keys($GLOBALS) as $glb){
             global $$glb;
@@ -95,8 +99,9 @@ class TestRequest {
      * with all set GET variables.
      *
      * @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'){
             throw new Exception("only '/doku.php' is supported currently");
         }
@@ -128,10 +133,9 @@ class TestRequest {
      * @param return TestResponse
      */
     public function post($post=array(), $uri='/doku.php') {
-        $this->setUri($uri);
         $this->post = array_merge($this->post, $post);
         $this->setServer('REQUEST_METHOD', 'POST');
-        return $this->execute();
+        return $this->execute($uri);
     }
 
     /**
@@ -143,9 +147,8 @@ class TestRequest {
      */
     public function get($get=array(), $uri='/doku.php') {
         $this->get  = array_merge($this->get, $get);
-        $this->setUri($uri);
         $this->setServer('REQUEST_METHOD', 'GET');
-        return $this->execute();
+        return $this->execute($uri);
     }
 
 
-- 
GitLab