public function testSetCookieGetFieldValueReturnsProperValue() { $setCookieHeader = new SetCookie(); $setCookieHeader->setName('myname'); $setCookieHeader->setValue('myvalue'); $setCookieHeader->setExpires('Wed, 13-Jan-2021 22:23:01 GMT'); $setCookieHeader->setDomain('docs.foo.com'); $setCookieHeader->setPath('/accounts'); $setCookieHeader->setSecure(true); $setCookieHeader->setHttponly(true); $target = 'myname=myvalue; Expires=Wed, 13-Jan-2021 22:23:01 GMT;' . ' Domain=docs.foo.com; Path=/accounts;' . ' Secure; HttpOnly'; $this->assertEquals($target, $setCookieHeader->getFieldValue()); }
public function testSetJsonValue() { $cookieName = "fooCookie"; $jsonData = json_encode(array('foo' => 'bar')); $cookie = new SetCookie($cookieName, $jsonData); $regExp = sprintf('#^%s=%s#', $cookieName, urlencode($jsonData)); $this->assertRegExp($regExp, $cookie->getFieldValue()); $cookieName = "fooCookie"; $jsonData = json_encode(array('foo' => 'bar')); $cookie = new SetCookie($cookieName, $jsonData); $cookie->setDomain('example.org'); $regExp = sprintf('#^%s=%s; Domain=#', $cookieName, urlencode($jsonData)); $this->assertRegExp($regExp, $cookie->getFieldValue()); }