MediaWiki  1.23.8
FauxResponseTest.php
Go to the documentation of this file.
1 <?php
27  protected $response;
28 
29  protected function setUp() {
30  parent::setUp();
31  $this->response = new FauxResponse;
32  }
33 
38  public function testCookie() {
39  $this->assertEquals( null, $this->response->getcookie( 'key' ), 'Non-existing cookie' );
40  $this->response->setcookie( 'key', 'val' );
41  $this->assertEquals( 'val', $this->response->getcookie( 'key' ), 'Existing cookie' );
42  }
43 
48  public function testHeader() {
49  $this->assertEquals( null, $this->response->getheader( 'Location' ), 'Non-existing header' );
50 
51  $this->response->header( 'Location: http://localhost/' );
52  $this->assertEquals( 'http://localhost/', $this->response->getheader( 'Location' ), 'Set header' );
53 
54  $this->response->header( 'Location: http://127.0.0.1/' );
55  $this->assertEquals( 'http://127.0.0.1/', $this->response->getheader( 'Location' ), 'Same header' );
56 
57  $this->response->header( 'Location: http://127.0.0.2/', false );
58  $this->assertEquals( 'http://127.0.0.1/', $this->response->getheader( 'Location' ), 'Same header with override disabled' );
59 
60  $this->response->header( 'Location: http://localhost/' );
61  $this->assertEquals( 'http://localhost/', $this->response->getheader( 'LOCATION' ), 'Get header case insensitive' );
62  }
63 
67  public function testResponseCode() {
68  $this->response->header( 'HTTP/1.1 200' );
69  $this->assertEquals( 200, $this->response->getStatusCode(), 'Header with no message' );
70 
71  $this->response->header( 'HTTP/1.x 201' );
72  $this->assertEquals( 201, $this->response->getStatusCode(), 'Header with no message and protocol 1.x' );
73 
74  $this->response->header( 'HTTP/1.1 202 OK' );
75  $this->assertEquals( 202, $this->response->getStatusCode(), 'Normal header' );
76 
77  $this->response->header( 'HTTP/1.x 203 OK' );
78  $this->assertEquals( 203, $this->response->getStatusCode(), 'Normal header with no message and protocol 1.x' );
79 
80  $this->response->header( 'HTTP/1.x 204 OK', false, 205 );
81  $this->assertEquals( 205, $this->response->getStatusCode(), 'Third parameter overrides the HTTP/... header' );
82 
83  $this->response->header( 'Location: http://localhost/', false, 206 );
84  $this->assertEquals( 206, $this->response->getStatusCode(), 'Third parameter with another header' );
85  }
86 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
FauxResponseTest
Definition: FauxResponseTest.php:25
FauxResponseTest\testCookie
testCookie()
@covers FauxResponse::getcookie @covers FauxResponse::setcookie
Definition: FauxResponseTest.php:37
FauxResponseTest\testHeader
testHeader()
@covers FauxResponse::getheader @covers FauxResponse::header
Definition: FauxResponseTest.php:47
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
FauxResponseTest\$response
FauxResponse $response
Definition: FauxResponseTest.php:26
FauxResponseTest\testResponseCode
testResponseCode()
@covers FauxResponse::getStatusCode
Definition: FauxResponseTest.php:66
FauxResponse
Definition: WebResponse.php:119
FauxResponseTest\setUp
setUp()
Definition: FauxResponseTest.php:28