From 495d0e366e0d9feea6c4873e567ea919093ff179 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 20 Apr 2013 19:50:53 +0200 Subject: [PATCH] [HttpFoundation] fixed empty domain= in Cookie::__toString() --- src/Symfony/Component/HttpFoundation/Cookie.php | 2 +- src/Symfony/Component/HttpFoundation/Tests/CookieTest.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Cookie.php b/src/Symfony/Component/HttpFoundation/Cookie.php index fe3a4cff42..43bf87dc23 100644 --- a/src/Symfony/Component/HttpFoundation/Cookie.php +++ b/src/Symfony/Component/HttpFoundation/Cookie.php @@ -95,7 +95,7 @@ class Cookie $str .= '; path='.$this->path; } - if (null !== $this->getDomain()) { + if ($this->getDomain()) { $str .= '; domain='.$this->getDomain(); } diff --git a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php index 6a9948d62a..bfedd27fe1 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/CookieTest.php @@ -117,11 +117,12 @@ class CookieTest extends \PHPUnit_Framework_TestCase public function testToString() { $cookie = new Cookie('foo', 'bar', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true); - $this->assertEquals('foo=bar; expires=Fri, 20-May-2011 15:25:52 GMT; domain=.myfoodomain.com; secure; httponly', $cookie->__toString(), '->__toString() returns string representation of the cookie'); $cookie = new Cookie('foo', null, 1, '/admin/', '.myfoodomain.com'); - $this->assertEquals('foo=deleted; expires=' . gmdate("D, d-M-Y H:i:s T", time()-31536001) . '; path=/admin/; domain=.myfoodomain.com; httponly', $cookie->__toString(), '->__toString() returns string representation of a cleared cookie if value is NULL'); + + $cookie = new Cookie('foo', 'bar', 0, '/', ''); + $this->assertEquals('foo=bar; httponly', $cookie->__toString()); } }