MediaWiki  REL1_19
FauxResponseTest.php
Go to the documentation of this file.
00001 <?php
00025 class FauxResponseTest extends MediaWikiTestCase {
00026         var $response;
00027 
00028         function setUp() {
00029                 $this->response = new FauxResponse;
00030         }
00031 
00032         function testCookie() {
00033                 $this->assertEquals( null, $this->response->getcookie( 'key' ), 'Non-existing cookie' );
00034                 $this->response->setcookie( 'key', 'val' );
00035                 $this->assertEquals( 'val', $this->response->getcookie( 'key' ), 'Existing cookie' );
00036         }
00037 
00038         function testHeader() {
00039                 $this->assertEquals( null, $this->response->getheader( 'Location' ), 'Non-existing header' );
00040 
00041                 $this->response->header( 'Location: http://localhost/' );
00042                 $this->assertEquals( 'http://localhost/', $this->response->getheader( 'Location' ), 'Set header' );
00043 
00044                 $this->response->header( 'Location: http://127.0.0.1/' );
00045                 $this->assertEquals( 'http://127.0.0.1/', $this->response->getheader( 'Location' ), 'Same header' );
00046 
00047                 $this->response->header( 'Location: http://127.0.0.2/', false );
00048                 $this->assertEquals( 'http://127.0.0.1/', $this->response->getheader( 'Location' ), 'Same header with override disabled' );
00049         }
00050 
00051         function testResponseCode() {
00052                 $this->response->header( 'HTTP/1.1 200' );
00053                 $this->assertEquals( 200, $this->response->getStatusCode(), 'Header with no message' );
00054 
00055                 $this->response->header( 'HTTP/1.x 201' );
00056                 $this->assertEquals( 201, $this->response->getStatusCode(), 'Header with no message and protocol 1.x' );
00057 
00058                 $this->response->header( 'HTTP/1.1 202 OK' );
00059                 $this->assertEquals( 202, $this->response->getStatusCode(), 'Normal header' );
00060 
00061                 $this->response->header( 'HTTP/1.x 203 OK' );
00062                 $this->assertEquals( 203, $this->response->getStatusCode(), 'Normal header with no message and protocol 1.x' );
00063 
00064                 $this->response->header( 'HTTP/1.x 204 OK', false, 205 );
00065                 $this->assertEquals( 205, $this->response->getStatusCode(), 'Third parameter overrides the HTTP/... header' );
00066 
00067                 $this->response->header( 'Location: http://localhost/', false, 206 );
00068                 $this->assertEquals( 206, $this->response->getStatusCode(), 'Third parameter with another header' );
00069         }
00070 }