Ejemplo n.º 1
0
 public function testConstructorAndDefaults()
 {
     $cookie = new Cookie('foo', 'bar');
     $this->assertSame('foo', $cookie->getName());
     $this->assertSame('bar', $cookie->getValue());
     $this->assertSame(0, $cookie->getExpires());
     $this->assertSame(null, $cookie->getPath());
     $this->assertSame(null, $cookie->getDomain());
     $this->assertFalse($cookie->isSecure());
     $this->assertFalse($cookie->isHttpOnly());
 }
Ejemplo n.º 2
0
 /**
  * Compares this cookie against another to determine which one should appear first in a Cookie header.
  *
  * The result is:
  *
  * * a negative number if this cookie should be returned before the other;
  * * a positive number if this cookie should be returned after the other;
  * * zero if the order does not matter.
  *
  * @param ClientCookie $that
  *
  * @return integer
  */
 public function compareTo(ClientCookie $that)
 {
     $thisLength = substr_count($this->cookie->getPath(), '/');
     $thatLength = substr_count($that->cookie->getPath(), '/');
     if ($thisLength == $thatLength) {
         // Among cookies that have equal-length path fields,
         // Cookies with earlier creation-times are listed first.
         return $this->creationTime - $that->creationTime;
     }
     // Cookies with longer paths are listed before cookies with shorter paths.
     return $thatLength - $thisLength;
 }