Example #1
0
 public function test_getters_and_setters()
 {
     $cookie = new Cookie();
     $this->assertFalse($cookie->hasName());
     $this->assertFalse($cookie->hasValue());
     $cookie->setName('foo');
     $this->assertTrue($cookie->hasName());
     $this->assertEquals('foo', $cookie->getName());
     $cookie->setValue('bar');
     $this->assertTrue($cookie->hasValue());
     $this->assertEquals('bar', $cookie->getValue());
     $this->assertFalse($cookie->hasPath());
     $this->assertEquals('/', $cookie->getPath());
     $cookie->setPath('foo');
     $this->assertTrue($cookie->hasPath());
     $this->assertEquals('foo', $cookie->getPath());
     $this->assertFalse($cookie->hasDomain());
     $cookie->setDomain('bar');
     $this->assertTrue($cookie->hasDomain());
     $this->assertEquals('bar', $cookie->getDomain());
     $this->assertNull($cookie->getExpires());
     $this->assertFalse($cookie->hasMaxAge());
     $cookie->setMaxAge(1);
     $this->assertTrue($cookie->hasMaxAge());
     $this->assertEquals(time() + 1, $cookie->getExpires());
     $this->assertEquals(1, $cookie->getMaxAge());
     $this->assertEquals(time() + 1, $cookie->getExpires());
     $this->assertTrue($cookie->isHttpOnly());
     $cookie->setHttpOnly(false);
     $this->assertFalse($cookie->isHttpOnly());
     $this->assertFalse($cookie->isSecure());
     $cookie->setSecure(true);
     $this->assertTrue($cookie->isSecure());
 }