/**
  * @covers Guzzle\Http\Plugin\CookiePlugin
  */
 public function testExtractsMultipleCookies()
 {
     $this->plugin->clearCookies();
     $response = Response::fromMessage("HTTP/1.1 200 OK\r\n" . "Set-Cookie: IU=deleted; expires=Wed, 03-Mar-2010 02:17:39 GMT; path=/; domain=127.0.0.1\r\n" . "Set-Cookie: PH=deleted; expires=Wed, 03-Mar-2010 02:17:39 GMT; path=/; domain=127.0.0.1\r\n" . "Set-Cookie: fpc=d=.Hm.yh4.1XmJWjJfs4orLQzKzPImxklQoxXSHOZATHUSEFciRueW_7704iYUtsXNEXq0M92Px2glMdWypmJ7HIQl6XIUvrZimWjQ3vIdeuRbI.FNQMAfcxu_XN1zSx7l.AcPdKL6guHc2V7hIQFhnjRW0rxm2oHY1P4bGQxFNz7f.tHm12ZD3DbdMDiDy7TBXsuP4DM-&v=2; expires=Fri, 02-Mar-2019 02:17:40 GMT; path=/; domain=127.0.0.1\r\n" . "Set-Cookie: FPCK3=AgBNbvoQAGpGEABZLRAAbFsQAF1tEABkDhAAeO0=; expires=Sat, 02-Apr-2019 02:17:40 GMT; path=/; domain=127.0.0.1\r\n" . "Set-Cookie: CH=deleted; expires=Wed, 03-Mar-2010 02:17:39 GMT; path=/; domain=127.0.0.1\r\n" . "Set-Cookie: CH=AgBNbvoQAAEcEAApuhAAMJcQADQvEAAvGxAALe0QAD6uEAATwhAAC1AQAC8t; expires=Sat, 02-Apr-2019 02:17:40 GMT; path=/; domain=127.0.0.1\r\n" . "Set-Cookie: fpt=d=_e2d6jLXesxx4AoiC0W7W3YktnpITDTHoJ6vNxF7TU6JEep6Y5BFk7Z9NgHmhiXoB7jGV4uR_GBQtSDOLjflKBUVZ6UgnGmDztoj4GREK30jm1qDgReyhPv7iWaN8e8ZLpUKXtPioOzQekGha1xR8ZqGR25GT7aYQpcxaaY.2ATjTpbm7HmX8tlBIte6mYMwFpIh_krxtofGPH3R337E_aNF3illhunC5SK6I0IfZvHzBXCoxu9fjH6e0IHzyOBY656YMUIElQiDkSd8werkBIRE6LJi6YU8AWgitEpMLisOIQSkqyGiahcPFt_fsD8DmIX2YAdSeVE0KycIqd0Z9aM7mdJ3xNQ4dmOOfcZ83dDrZ.4hvuKN2jB2FQDKuxEjTVO4DmiCCSyYgcs2wh0Lc3RODVKzqAZNMTYltWMELw9JdUyDFD3EGT3ZCnH8NQ6f_AAWffyj92ZMLYfWJnXHSG.DTKlVHj.IsihVT73QzrfoMFIs&v=1; path=/; domain=127.0.0.1\r\n" . "Set-Cookie: fpps=deleted; expires=Wed, 03-Mar-2010 02:17:39 GMT; path=/; domain=127.0.0.1\r\n" . "set-cookie: fpc_s=d=ng6sEJk.1XnLUt1pfJ2kiUon07QEppAUuwW3nk0tYwcHMQ1CijnSGVZHfgvWSXQxE5eW_1hjvDAA4Nu0CSSn2xk9_.DOkKI_fZLLLUrm0hJ41VMbSUTrklw.u5IlTM5JCeK_PDjSjZNkvHMbNYziu8vwd8fMnbecf9bSo3eDDv1boowyLFk_9mnGYBeSI4U86mnm.mnfOHMARxzL6BVMTAblIAml65cR486SHzPVO6KNYvkqh8zP3m0hVIkRaPhzvDjQkDG28HCbMjq745QR2FcCmI4TNJbk7EtJmsBrlL8wvVyX5DiBmP9W990-&v=2; path=/; domain=127.0.0.1\r\n" . "Content-Length: 0\r\n\r\n");
     $this->getServer()->enqueue(array((string) $response, "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\rn"));
     $request = RequestFactory::getInstance()->create('GET', $this->getServer()->getUrl());
     $request->getEventDispatcher()->addSubscriber($this->plugin);
     $request->setClient(new Client());
     $request->send();
     $this->assertNull($request->getHeader('Cookie'));
     $request->setState('new');
     $request->send();
     $this->assertNotNull($request->getHeader('Cookie'));
     // Doesn't send expired cookies
     $this->assertEmpty($request->getCookie('IU'));
     $this->assertEmpty($request->getCookie('PH'));
     $this->assertNotEmpty($request->getCookie('fpc'));
     $this->assertNotEmpty($request->getCookie('FPCK3'));
     $this->assertNotEmpty($request->getCookie('CH'));
     $this->assertNotEmpty($request->getCookie('fpt'));
     $this->assertNotEmpty($request->getCookie('fpc_s'));
     $this->assertNotEmpty($request->getCookie('CH'));
     $this->assertNotEmpty($request->getCookie('CH'));
     $this->assertEquals(9, count($this->plugin->extractCookies($response)));
 }
Example #2
0
 public function testProvidesCookieJar()
 {
     $jar = new ArrayCookieJar();
     $plugin = new CookiePlugin($jar);
     $this->assertSame($jar, $plugin->getCookieJar());
 }