X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=phpunit%2FCookieTest.php;h=affe798dbb647c7bf130a02ffb472635e4ff065e;hp=a1a75db576a9b6c58ac39269f7c9f36c8b7d5c89;hb=8df0e5b02cd04b43f19045c0f4f69c4076840d27;hpb=b4920d7ad19ae6704e10cb29fca652b47e1bc61f diff --git a/phpunit/CookieTest.php b/phpunit/CookieTest.php index a1a75db..affe798 100644 --- a/phpunit/CookieTest.php +++ b/phpunit/CookieTest.php @@ -10,7 +10,8 @@ class CookieTest extends PHPUnit_Framework_TestCase { "flags" => 0, "expires" => -1, "path" => "", - "domain" => "" + "domain" => "", + "max-age" => -1, ); $this->assertEquals($a, $c->toArray()); $this->assertEquals($a, $o->toArray()); @@ -40,6 +41,7 @@ class CookieTest extends PHPUnit_Framework_TestCase { foreach (array($orig, $copy) as $c) { $this->assertEquals("value", $c->getCookie("key")); $this->assertEquals(-1, $c->getExpires()); + $this->assertEquals(-1, $c->getMaxAge()); $this->assertEquals(0, $c->getFlags()); $this->assertEquals(null, $c->getPath()); $this->assertEquals(null, $c->getDomain()); @@ -59,6 +61,7 @@ class CookieTest extends PHPUnit_Framework_TestCase { "expires" => -1, "path" => "", "domain" => "", + "max-age" => -1, ), $c->toArray() ); @@ -86,6 +89,24 @@ class CookieTest extends PHPUnit_Framework_TestCase { ); } + function testMaxAge() { + $c = new http\Cookie("this=max-age; max-age=12345"); + $this->assertEquals("max-age", $c->getCookie("this")); + $this->assertEquals(12345, $c->getMaxAge()); + $o = clone $c; + $t = 54321; + $o->setMaxAge(); + $this->assertEquals(-1, $o->getMaxAge()); + $this->assertNotEquals(-1, $c->getMaxAge()); + $o->setMaxAge($t); + $this->assertEquals($t, $o->getMaxAge()); + $this->assertNotEquals($t, $c->getMaxAge()); + $this->assertEquals( + "this=max-age; max-age=$t; ", + $o->toString() + ); + } + function testPath() { $c = new http\Cookie("this=has a path; path=/down; "); $this->assertEquals("has a path", $c->getCookie("this"));