/** * Return an instance with the specified cookies. * * The data IS NOT REQUIRED to come from the $_COOKIE superglobal, but MUST * be compatible with the structure of $_COOKIE. Typically, this data will * be injected at instantiation. * * This method MUST NOT update the related Cookie header of the request * instance, nor related values in the server params. * * This method MUST be implemented in such a way as to retain the * immutability of the message, and MUST return an instance that has the * updated cookie values. * * @param array $cookies Array of key/value pairs representing cookies. * @return static */ public function withCookieParams(array $cookies) { while (list($name, $value) = each($cookies)) { $this->cookie->set($name, $value); } return $this; }
public function testToStringForCookieBag() { $cookieBag = new CookieBag(); $cookieBag->set('name', 'jan'); $this->assertEquals(1, count($cookieBag->all())); }