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

Merge pull request #529 from lisps/TestRequest

fix TestRequest
parents 0931b30c fe717f57
No related branches found
No related tags found
No related merge requests found
...@@ -44,13 +44,18 @@ class TestRequest { ...@@ -44,13 +44,18 @@ class TestRequest {
* @return TestResponse the resulting output of the request * @return TestResponse the resulting output of the request
*/ */
public function execute($uri='/doku.php') { public function execute($uri='/doku.php') {
global $INPUT;
global $ID;
global $INFO;
// save old environment // save old environment
$server = $_SERVER; $server = $_SERVER;
$session = $_SESSION; $session = $_SESSION;
$get = $_GET; $get = $_GET;
$post = $_POST; $post = $_POST;
$request = $_REQUEST; $request = $_REQUEST;
$input = $INPUT;
// prepare the right URI // prepare the right URI
$this->setUri($uri); $this->setUri($uri);
...@@ -74,6 +79,7 @@ class TestRequest { ...@@ -74,6 +79,7 @@ class TestRequest {
// now execute dokuwiki and grep the output // now execute dokuwiki and grep the output
header_remove(); header_remove();
ob_start('ob_start_callback'); ob_start('ob_start_callback');
$INPUT = new Input();
include(DOKU_INC.$this->script); include(DOKU_INC.$this->script);
ob_end_flush(); ob_end_flush();
...@@ -89,6 +95,7 @@ class TestRequest { ...@@ -89,6 +95,7 @@ class TestRequest {
$_GET = $get; $_GET = $get;
$_POST = $post; $_POST = $post;
$_REQUEST = $request; $_REQUEST = $request;
$INPUT = $input;
return $response; return $response;
} }
......
...@@ -33,7 +33,7 @@ class InttestsBasicTest extends DokuWikiTest { ...@@ -33,7 +33,7 @@ class InttestsBasicTest extends DokuWikiTest {
$response = $request->execute(); $response = $request->execute();
$this->assertTrue( $this->assertTrue(
strpos($response->getContent(), 'DokuWiki') >= 0, strpos($response->getContent(), 'DokuWiki') !== false,
'DokuWiki was not a word in the output' 'DokuWiki was not a word in the output'
); );
} }
...@@ -60,7 +60,7 @@ class InttestsBasicTest extends DokuWikiTest { ...@@ -60,7 +60,7 @@ class InttestsBasicTest extends DokuWikiTest {
$this->assertEquals('wiki:dokuwiki', $request->getPost('id')); $this->assertEquals('wiki:dokuwiki', $request->getPost('id'));
// output check // output check
$this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0); $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') !== false);
} }
function testPostGet() { function testPostGet() {
...@@ -84,7 +84,7 @@ class InttestsBasicTest extends DokuWikiTest { ...@@ -84,7 +84,7 @@ class InttestsBasicTest extends DokuWikiTest {
$this->assertEquals('wiki:dokuwiki', $request->getGet('id')); $this->assertEquals('wiki:dokuwiki', $request->getGet('id'));
// output check // output check
$this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0); $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') !== false);
} }
function testGet() { function testGet() {
...@@ -116,7 +116,7 @@ class InttestsBasicTest extends DokuWikiTest { ...@@ -116,7 +116,7 @@ class InttestsBasicTest extends DokuWikiTest {
$this->assertEquals('bar', $request->getGet('test')); $this->assertEquals('bar', $request->getGet('test'));
// output check // output check
$this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') >= 0); $this->assertTrue(strpos($response->getContent(), 'Andreas Gohr') !== false);
} }
function testScripts() { function testScripts() {
...@@ -168,5 +168,13 @@ class InttestsBasicTest extends DokuWikiTest { ...@@ -168,5 +168,13 @@ class InttestsBasicTest extends DokuWikiTest {
$response = new TestResponse('',array_slice($this->some_headers,0,-2)); // slice off the last two headers to leave no status header $response = new TestResponse('',array_slice($this->some_headers,0,-2)); // slice off the last two headers to leave no status header
$this->assertNull($response->getStatusCode()); $this->assertNull($response->getStatusCode());
} }
function testINPUT() {
$request = new TestRequest();
$response = $request->get(array('id' => 'mailinglist'), '/doku.php');
// output check
$this->assertTrue(strpos($response->getContent(), 'Netiquette') !== false);
}
} }
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