Пример #1
0
 public function testAddsCookiesFromResponseWithNoRequest()
 {
     $response = new Response(200, array('Set-Cookie' => array("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", "FPCK3=AgBNbvoQAGpGEABZLRAAbFsQAF1tEABkDhAAeO0=; expires=Sat, 02-Apr-2019 02:17:40 GMT; path=/; domain=127.0.0.1", "CH=deleted; expires=Wed, 03-Mar-2010 02:17:39 GMT; path=/; domain=127.0.0.1", "CH=AgBNbvoQAAEcEAApuhAAMJcQADQvEAAvGxAALe0QAD6uEAATwhAAC1AQAC8t; expires=Sat, 02-Apr-2019 02:17:40 GMT; path=/; domain=127.0.0.1")));
     $this->jar->addCookiesFromResponse($response);
     $this->assertEquals(3, count($this->jar));
     $this->assertEquals(1, count($this->jar->all(null, null, 'fpc')));
     $this->assertEquals(1, count($this->jar->all(null, null, 'FPCK3')));
     $this->assertEquals(1, count($this->jar->all(null, null, 'CH')));
 }
Пример #2
0
 public function testRemoveExistingCookieIfEmpty()
 {
     // Add a cookie that should not be affected
     $a = new Cookie(array('name' => 'foo', 'value' => 'nope', 'domain' => 'foo.com', 'path' => '/abc'));
     $this->jar->add($a);
     $data = array('name' => 'foo', 'value' => 'bar', 'domain' => 'foo.com', 'path' => '/');
     $b = new Cookie($data);
     $this->assertTrue($this->jar->add($b));
     $this->assertEquals(2, count($this->jar));
     // Try to re-set the same cookie with no value: assert that cookie is not added
     $data['value'] = null;
     $this->assertFalse($this->jar->add(new Cookie($data)));
     // assert that original cookie has been deleted
     $cookies = $this->jar->all('foo.com');
     $this->assertTrue(in_array($a, $cookies, true));
     $this->assertFalse(in_array($b, $cookies, true));
     $this->assertEquals(1, count($this->jar));
 }