private function add_cookies(puzzle_message_RequestInterface $request, $value) { if ($value === true) { static $cookie = null; if (!$cookie) { $cookie = new puzzle_subscriber_Cookie(); } $request->getEmitter()->attach($cookie); } elseif (is_array($value)) { $request->getEmitter()->attach(new puzzle_subscriber_Cookie(puzzle_cookie_CookieJar::fromArray($value, $request->getHost()))); } elseif ($value instanceof puzzle_cookie_CookieJarInterface) { $request->getEmitter()->attach(new puzzle_subscriber_Cookie($value)); } elseif ($value !== false) { throw new InvalidArgumentException('cookies must be an array, ' . 'true, or a puzzle_cookie_CookieJarInterface object'); } }
public function testCreatesFromArray() { $jar = puzzle_cookie_CookieJar::fromArray(array('foo' => 'bar', 'baz' => 'bam'), 'example.com'); $this->assertCount(2, $jar); }