summaryrefslogtreecommitdiffstats
path: root/tests/lib/appframework/http/ResponseTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/appframework/http/ResponseTest.php')
-rw-r--r--tests/lib/appframework/http/ResponseTest.php86
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/lib/appframework/http/ResponseTest.php b/tests/lib/appframework/http/ResponseTest.php
index 04e19fdaf71..b4352348bae 100644
--- a/tests/lib/appframework/http/ResponseTest.php
+++ b/tests/lib/appframework/http/ResponseTest.php
@@ -76,6 +76,92 @@ class ResponseTest extends \Test\TestCase {
}
+ public function testAddCookie() {
+ $this->childResponse->addCookie('foo', 'bar');
+ $this->childResponse->addCookie('bar', 'foo', new \DateTime('1970-01-01'));
+
+ $expectedResponse = array(
+ 'foo' => array(
+ 'value' => 'bar',
+ 'expireDate' => null,
+ ),
+ 'bar' => array(
+ 'value' => 'foo',
+ 'expireDate' => new \DateTime('1970-01-01')
+ )
+ );
+ $this->assertEquals($expectedResponse, $this->childResponse->getCookies());
+ }
+
+
+ function testSetCookies() {
+ $expected = array(
+ 'foo' => array(
+ 'value' => 'bar',
+ 'expireDate' => null,
+ ),
+ 'bar' => array(
+ 'value' => 'foo',
+ 'expireDate' => new \DateTime('1970-01-01')
+ )
+ );
+
+ $this->childResponse->setCookies($expected);
+ $cookies = $this->childResponse->getCookies();
+
+ $this->assertEquals($expected, $cookies);
+ }
+
+
+ function testInvalidateCookie() {
+ $this->childResponse->addCookie('foo', 'bar');
+ $this->childResponse->invalidateCookie('foo');
+ $expected = array(
+ 'foo' => array(
+ 'value' => 'expired',
+ 'expireDate' => new \DateTime('1971-01-01')
+ )
+ );
+
+ $cookies = $this->childResponse->getCookies();
+
+ $this->assertEquals($expected, $cookies);
+ }
+
+
+ function testInvalidateCookies() {
+ $this->childResponse->addCookie('foo', 'bar');
+ $this->childResponse->addCookie('bar', 'foo');
+ $expected = array(
+ 'foo' => array(
+ 'value' => 'bar',
+ 'expireDate' => null
+ ),
+ 'bar' => array(
+ 'value' => 'foo',
+ 'expireDate' => null
+ )
+ );
+ $cookies = $this->childResponse->getCookies();
+ $this->assertEquals($expected, $cookies);
+
+ $this->childResponse->invalidateCookies(array('foo', 'bar'));
+ $expected = array(
+ 'foo' => array(
+ 'value' => 'expired',
+ 'expireDate' => new \DateTime('1971-01-01')
+ ),
+ 'bar' => array(
+ 'value' => 'expired',
+ 'expireDate' => new \DateTime('1971-01-01')
+ )
+ );
+
+ $cookies = $this->childResponse->getCookies();
+ $this->assertEquals($expected, $cookies);
+ }
+
+
public function testRenderReturnNullByDefault(){
$this->assertEquals(null, $this->childResponse->render());
}