LocalisationCache: try harder to use LCStoreCDB
[lhc/web/wiklou.git] / tests / phpunit / includes / FauxResponseTest.php
index 4a974ba..8c104d9 100644 (file)
@@ -32,13 +32,36 @@ class FauxResponseTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers FauxResponse::getcookie
-        * @covers FauxResponse::setcookie
+        * @covers FauxResponse::setCookie
+        * @covers FauxResponse::getCookie
+        * @covers FauxResponse::getCookieData
+        * @covers FauxResponse::getCookies
         */
        public function testCookie() {
-               $this->assertEquals( null, $this->response->getcookie( 'key' ), 'Non-existing cookie' );
-               $this->response->setcookie( 'key', 'val' );
-               $this->assertEquals( 'val', $this->response->getcookie( 'key' ), 'Existing cookie' );
+               $expire = time() + 100;
+               $cookie = array(
+                       'value' => 'val',
+                       'path' => '/path',
+                       'domain' => 'domain',
+                       'secure' => true,
+                       'httpOnly' => false,
+                       'raw' => false,
+                       'expire' => $expire,
+               );
+
+               $this->assertEquals( null, $this->response->getCookie( 'xkey' ), 'Non-existing cookie' );
+               $this->response->setCookie( 'key', 'val', $expire, array(
+                       'prefix' => 'x',
+                       'path' => '/path',
+                       'domain' => 'domain',
+                       'secure' => 1,
+                       'httpOnly' => 0,
+               ) );
+               $this->assertEquals( 'val', $this->response->getCookie( 'xkey' ), 'Existing cookie' );
+               $this->assertEquals( $cookie, $this->response->getCookieData( 'xkey' ),
+                       'Existing cookie (data)' );
+               $this->assertEquals( array( 'xkey' => $cookie ), $this->response->getCookies(),
+                       'Existing cookies' );
        }
 
        /**
@@ -108,6 +131,13 @@ class FauxResponseTest extends MediaWikiTestCase {
                        'Third parameter overrides the HTTP/... header'
                );
 
+               $this->response->statusHeader( 210 );
+               $this->assertEquals(
+                       210,
+                       $this->response->getStatusCode(),
+                       'Handle statusHeader method'
+               );
+
                $this->response->header( 'Location: http://localhost/', false, 206 );
                $this->assertEquals(
                        206,