/** * @dataProvider sampleDataProvider */ public function testConstructorRoutesThroughSet($sample_cookie, $sample_other_cookie) { $array_of_cookie_instances = array($sample_cookie, $sample_other_cookie, new ResponseCookie('test')); // Create our collection with NO data $data_collection = new ResponseCookieDataCollection($array_of_cookie_instances); $this->assertSame($array_of_cookie_instances, $data_collection->all()); foreach ($data_collection as $cookie) { $this->assertTrue($cookie instanceof ResponseCookie); } }
/** * Sets a response cookie * * @param string $key The name of the cookie * @param string $value The value to set the cookie with * @param int $expiry The time that the cookie should expire * @param string $path The path of which to restrict the cookie * @param string $domain The domain of which to restrict the cookie * @param boolean $secure Flag of whether the cookie should only be sent over a HTTPS connection * @param boolean $httponly Flag of whether the cookie should only be accessible over the HTTP protocol * @access public * @return Response */ public function cookie($key, $value = '', $expiry = null, $path = '/', $domain = null, $secure = false, $httponly = false) { if (null === $expiry) { $expiry = time() + 3600 * 24 * 30; } $this->cookies->set($key, new ResponseCookie($key, $value, $expiry, $path, $domain, $secure, $httponly)); return $this; }