Permalink
Browse files

Merge branch 'hotfix/ZF2-254' of https://github.com/adamlundrigan/zf2

…into hotfix/zf2-254
  • Loading branch information...
weierophinney committed Apr 9, 2012
2 parents 31f7b52 + f02ba21 commit ab7c575ed3d6856ca5f3753cb4e8fec6779b19a3
Showing with 28 additions and 1 deletion.
  1. +9 −1 library/Zend/Http/Header/SetCookie.php
  2. +19 −0 tests/Zend/Http/Header/SetCookieTest.php
@@ -155,7 +155,7 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false)
* @param bool $httponly
* @return SetCookie
*/
- public function __construct($name = null, $value = null, $version = null, $maxAge = null, $domain = null, $expires = null, $path = null, $secure = false, $httponly = true)
+ public function __construct($name = null, $value = null, $version = null, $maxAge = null, $domain = null, $expires = null, $path = null, $secure = false, $httponly = false)
{
$this->type = 'Cookie';
@@ -183,9 +183,17 @@ public function __construct($name = null, $value = null, $version = null, $maxAg
$this->setExpires($expires);
}
+ if ($path) {
+ $this->setPath($path);
+ }
+
if ($secure) {
$this->setSecure($secure);
}
+
+ if ($httponly) {
+ $this->setHttpOnly($httponly);
+ }
}
/**
@@ -6,6 +6,25 @@
class SetCookieTest extends \PHPUnit_Framework_TestCase
{
+ /**
+ * @group ZF2-254
+ */
+ public function testSetCookieConstructor()
+ {
+ $setCookieHeader = new SetCookie(
+ 'myname', 'myvalue', 9, 99, 'docs.foo.com',
+ 'Wed, 13-Jan-2021 22:23:01 GMT', '/accounts', true, true
+ );
+ $this->assertEquals('myname', $setCookieHeader->getName());
+ $this->assertEquals('myvalue', $setCookieHeader->getValue());
+ $this->assertEquals(9, $setCookieHeader->getVersion());
+ $this->assertEquals(99, $setCookieHeader->getMaxAge());
+ $this->assertEquals('docs.foo.com', $setCookieHeader->getDomain());
+ $this->assertEquals('Wed, 13-Jan-2021 22:23:01 GMT', $setCookieHeader->getExpires());
+ $this->assertEquals('/accounts', $setCookieHeader->getPath());
+ $this->assertTrue($setCookieHeader->isSecure());
+ $this->assertTrue($setCookieHeader->isHttpOnly());
+ }
public function testSetCookieFromStringCreatesValidSetCookieHeader()
{

0 comments on commit ab7c575

Please sign in to comment.