소스 검색

fixed typos

Fabien Potencier 15 년 전
부모
커밋
1b9645b098

+ 4 - 4
src/Symfony/Components/BrowserKit/Cookie.php

@@ -65,14 +65,14 @@ class Cookie
             $cookie .= '; expires='.substr(\DateTime::createFromFormat('U', $this->expires, new \DateTimeZone('UTC'))->format(static::DATE_FORMAT), 0, -5);
         }
 
-        if ('/' !== $this->path) {
-            $cookie .= '; path='.$this->path;
-        }
-
         if ('' !== $this->domain) {
             $cookie .= '; domain='.$this->domain;
         }
 
+        if ('/' !== $this->path) {
+            $cookie .= '; path='.$this->path;
+        }
+
         if ($this->secure) {
             $cookie .= '; secure';
         }

+ 3 - 5
src/Symfony/Components/HttpKernel/HeaderBag.php

@@ -204,7 +204,7 @@ class HeaderBag
             } else {
                 $expires = strtotime($expires);
                 if (false === $expires || -1 == $expires) {
-                    throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid.', $expire));
+                    throw new \InvalidArgumentException(sprintf('The "expires" cookie parameter is not valid.', $expires));
                 }
             }
         }
@@ -213,14 +213,12 @@ class HeaderBag
             $cookie .= '; expires='.substr(\DateTime::createFromFormat('U', $expires, new \DateTimeZone('UTC'))->format('D, d-M-Y H:i:s T'), 0, -5);
         }
 
+        $cookie .= '; domain='.$domain;
+
         if ('/' !== $path) {
             $cookie .= '; path='.$path;
         }
 
-        if ('' !== $domain) {
-            $cookie .= '; domain='.$domain;
-        }
-
         if ($secure) {
             $cookie .= '; secure';
         }

+ 2 - 2
tests/Symfony/Tests/Components/BrowserKit/CookieTest.php

@@ -32,14 +32,14 @@ class CookieTest extends \PHPUnit_Framework_TestCase
             array('foo=bar; domain=google.com'),
             array('foo=bar; secure'),
             array('foo=bar; httponly'),
-            array('foo=bar; path=/foo; domain=google.com; secure; httponly'),
+            array('foo=bar; domain=google.com; path=/foo; secure; httponly'),
         );
     }
 
     public function testFromStringWithUrl()
     {
         $this->assertEquals('foo=bar; domain=www.example.com', (string) Cookie::FromString('foo=bar', 'http://www.example.com/'));
-        $this->assertEquals('foo=bar; path=/foo; domain=www.example.com', (string) Cookie::FromString('foo=bar', 'http://www.example.com/foo/bar'));
+        $this->assertEquals('foo=bar; domain=www.example.com; path=/foo', (string) Cookie::FromString('foo=bar', 'http://www.example.com/foo/bar'));
     }
 
     public function testFromStringThrowsAnExceptionIfCookieIsNotValid()