diff options
author | Christopher Smith <chris@jalakai.co.uk> | 2013-03-22 18:01:45 +0000 |
---|---|---|
committer | Christopher Smith <chris@jalakai.co.uk> | 2013-03-22 18:01:45 +0000 |
commit | fb0b3fbf03223c8c304608cdb32ee5c9d755eca1 (patch) | |
tree | 4a417efffa52bcb536dbc9846c9623c3e560ed54 /_test/tests/test | |
parent | 9894e7afaae16cc0699afbe839681e023afee65a (diff) | |
download | rpg-fb0b3fbf03223c8c304608cdb32ee5c9d755eca1.tar.gz rpg-fb0b3fbf03223c8c304608cdb32ee5c9d755eca1.tar.bz2 |
update TestResponse class to return specific headers & status codes (with tests)
Diffstat (limited to '_test/tests/test')
-rw-r--r-- | _test/tests/test/basic.test.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/_test/tests/test/basic.test.php b/_test/tests/test/basic.test.php index c40f2d574..1c9d6d516 100644 --- a/_test/tests/test/basic.test.php +++ b/_test/tests/test/basic.test.php @@ -4,6 +4,24 @@ * @group integration */ class InttestsBasicTest extends DokuWikiTest { + + private $some_headers = array( + 'Content-Type: image/png', + 'Date: Fri, 22 Mar 2013 16:10:01 GMT', + 'X-Powered-By: PHP/5.3.15', + 'Expires: Sat, 23 Mar 2013 17:03:46 GMT', + 'Cache-Control: public, proxy-revalidate, no-transform, max-age=86400', + 'Pragma: public', + 'Last-Modified: Fri, 22 Mar 2013 01:48:28 GMT', + 'ETag: "63daab733b38c30c337229b2e587f8fb"', + 'Content-Disposition: inline; filename="fe389b0db8c1088c336abb502d2f9ae7.media.200x200.png', + 'Accept-Ranges: bytes', + 'Content-Type: image/png', + 'Content-Length: 62315', + 'Status: 200 OK', + 'Status: 404 Not Found', + ); + /** * Execute the simplest possible request and expect * a dokuwiki page which obviously has the word "DokuWiki" @@ -120,4 +138,27 @@ class InttestsBasicTest extends DokuWikiTest { $this->assertEquals('lib/exe/detail.php',$request->getScript()); } + function testHeaders(){ + $request = new TestRequest(); + $response = $request->get(array(),'/lib/exe/fetch.php?media=wiki:dokuwiki-128.png'); + $headers = $response->getHeaders();
+ $this->assertTrue(!empty($headers));
+ } + + function testGetHeader(){ + $response = new TestResponse('',$this->some_headers); + + $this->assertEquals('Pragma: public', $response->getHeader('Pragma')); + $this->assertEmpty($response->getHeader('Junk')); + $this->assertEquals(array('Content-Type: image/png','Content-Type: image/png'), $response->getHeader('Content-Type')); + } + + function testGetStatus(){ + $response = new TestResponse('',$this->some_headers); + $this->assertEquals(404, $response->getStatusCode()); + + $response = new TestResponse('',array_slice($this->some_headers,0,-2)); // slide off the last two headers to leave no status header + $this->assertNull($response->getStatusCode()); + } + } |