Ejemplo n.º 1
0
 public function testHoldsValues()
 {
     $t = time();
     $data = array('Name' => 'foo', 'Value' => 'baz', 'Path' => '/bar', 'Domain' => 'baz.com', 'Expires' => $t, 'Max-Age' => 100, 'Secure' => true, 'Discard' => true, 'HttpOnly' => true, 'foo' => 'baz', 'bar' => 'bam');
     $cookie = new SetCookie($data);
     $this->assertEquals($data, $cookie->toArray());
     $this->assertEquals('foo', $cookie->getName());
     $this->assertEquals('baz', $cookie->getValue());
     $this->assertEquals('baz.com', $cookie->getDomain());
     $this->assertEquals('/bar', $cookie->getPath());
     $this->assertEquals($t, $cookie->getExpires());
     $this->assertEquals(100, $cookie->getMaxAge());
     $this->assertTrue($cookie->getSecure());
     $this->assertTrue($cookie->getDiscard());
     $this->assertTrue($cookie->getHttpOnly());
     $this->assertEquals('baz', $cookie->toArray()['foo']);
     $this->assertEquals('bam', $cookie->toArray()['bar']);
     $cookie->setName('a')->setValue('b')->setPath('c')->setDomain('bar.com')->setExpires(10)->setMaxAge(200)->setSecure(false)->setHttpOnly(false)->setDiscard(false);
     $this->assertEquals('a', $cookie->getName());
     $this->assertEquals('b', $cookie->getValue());
     $this->assertEquals('c', $cookie->getPath());
     $this->assertEquals('bar.com', $cookie->getDomain());
     $this->assertEquals(10, $cookie->getExpires());
     $this->assertEquals(200, $cookie->getMaxAge());
     $this->assertFalse($cookie->getSecure());
     $this->assertFalse($cookie->getDiscard());
     $this->assertFalse($cookie->getHttpOnly());
 }
Ejemplo n.º 2
0
 /**
  * If a cookie already exists and the server asks to set it again with a
  * null value, the cookie must be deleted.
  *
  * @param SetCookie $cookie
  */
 private function removeCookieIfEmpty(SetCookie $cookie)
 {
     $cookieValue = $cookie->getValue();
     if ($cookieValue === null || $cookieValue === '') {
         $this->clear($cookie->getDomain(), $cookie->getPath(), $cookie->getName());
     }
 }
Ejemplo n.º 3
0
 public function getColor()
 {
     return $this->colorCookie->getValue();
 }