summaryrefslogtreecommitdiff
path: root/_test/core
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2013-03-22 17:59:23 +0000
committerChristopher Smith <chris@jalakai.co.uk>2013-03-22 17:59:23 +0000
commit9894e7afaae16cc0699afbe839681e023afee65a (patch)
treef367abdb43b84916f2ed3ed5bda4c38eddf39965 /_test/core
parentb051e9742775994c33cb6570e27605bbe930efe4 (diff)
downloadrpg-9894e7afaae16cc0699afbe839681e023afee65a.tar.gz
rpg-9894e7afaae16cc0699afbe839681e023afee65a.tar.bz2
extend TestRequest class to test fetch & detail; add a test to check it does
Diffstat (limited to '_test/core')
-rw-r--r--_test/core/TestRequest.php19
1 files changed, 12 insertions, 7 deletions
diff --git a/_test/core/TestRequest.php b/_test/core/TestRequest.php
index 172821576..0a54910ed 100644
--- a/_test/core/TestRequest.php
+++ b/_test/core/TestRequest.php
@@ -18,6 +18,9 @@ function ob_start_callback($buffer) {
*/
class TestRequest {
+ private $valid_scripts = array('/doku.php', '/lib/exe/fetch.php', '/lib/exe/detail.php');
+ private $script;
+
private $server = array();
private $session = array();
private $get = array();
@@ -27,6 +30,7 @@ class TestRequest {
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 getScript() { return $this->script; }
public function setServer($key, $value) { $this->server[$key] = $value; }
public function setSession($key, $value) { $this->session[$key] = $value; }
@@ -70,13 +74,13 @@ class TestRequest {
// now execute dokuwiki and grep the output
header_remove();
ob_start('ob_start_callback');
- include(DOKU_INC.'doku.php');
+ include(DOKU_INC.$this->script);
ob_end_flush();
// create the response object
$response = new TestResponse(
$output_buffer,
- headers_list()
+ (function_exists('xdebug_get_headers') ? xdebug_get_headers() : headers_list()) // cli sapi doesn't do headers, prefer xdebug_get_headers() which works under cli
);
// reset environment
@@ -102,14 +106,15 @@ class TestRequest {
* @todo make this work with other end points
*/
protected function setUri($uri){
- if(substr($uri,0,9) != '/doku.php'){
- throw new Exception("only '/doku.php' is supported currently");
+ if(!preg_match('#^('.join('|',$this->valid_scripts).')#',$uri)){
+ throw new Exception("$uri \n--- only ".join(', ',$this->valid_scripts)." are supported currently");
}
$params = array();
list($uri, $query) = explode('?',$uri,2);
if($query) parse_str($query, $params);
+ $this->script = substr($uri,1);
$this->get = array_merge($params, $this->get);
if(count($this->get)){
$query = '?'.http_build_query($this->get, '', '&');
@@ -129,7 +134,7 @@ class TestRequest {
* Simulate a POST request with the given variables
*
* @param array $post all the POST parameters to use
- * @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, /lib/exe/fetch.php or /lib/exe/detail.php currently
* @param return TestResponse
*/
public function post($post=array(), $uri='/doku.php') {
@@ -141,8 +146,8 @@ class TestRequest {
/**
* Simulate a GET request with the given variables
*
- * @param array $GET all the POST parameters to use
- * @param string $url end URL to simulate, needs to start with /doku.php currently
+ * @param array $GET all the GET parameters to use
+ * @param string $url end URL to simulate, needs to start with /doku.php, /lib/exe/fetch.php or /lib/exe/detail.php currently
* @param return TestResponse
*/
public function get($get=array(), $uri='/doku.php') {