Example #1
0
 public function testIfArrayIteratorOfHeadersCanBeSet()
 {
     $headers = new \ArrayIterator(array(new SetCookie('foo'), new SetCookie('bar')));
     $client = new Client();
     $client->addCookie($headers);
     $cookies = $client->getCookies();
     $this->assertEquals(2, count($cookies));
 }
Example #2
0
 /**
  * Test sending cookie header with raw value
  *
  * @group fix-double-encoding-problem-about-cookie-value
  */
 public function testRawCookiesInRequestHeaders()
 {
     $this->_client->setConfig(array('encodecookies' => false));
     $this->_client->addCookie('foo', 'bar=baz');
     $this->_client->send();
     $cookieValue = 'Cookie: foo=bar=baz';
     $this->assertContains($cookieValue, $this->_client->getLastRawRequest(), 'Request is expected to contain the entire cookie "keyname=raw_value"');
 }
 protected function getClient($url)
 {
     $http_client = new HttpClient(null, ['timeout' => $this->timeout]);
     $http_client->setHeaders(['User-Agent' => 'OpenErpByJsonRpc by ZendJsonRpc']);
     if (null !== $this->cookie) {
         $http_client->addCookie($this->cookie);
     }
     $this->client = new Client($url, $http_client);
     return $this->client;
 }
Example #4
0
 /**
  * Test sending cookie header with raw value
  *
  * @group fix-double-encoding-problem-about-cookie-value
  */
 public function testRawCookiesInRequestHeaders()
 {
     if (!constant('TESTS_ZEND_HTTP_CLIENT_ONLINE')) {
         $this->markTestSkipped('Zend\\Http\\Client online tests are not enabled');
     }
     $this->_client->setOptions(array('encodecookies' => false));
     $this->_client->addCookie('foo', 'bar=baz');
     $this->_client->send();
     $cookieValue = 'Cookie: foo=bar=baz';
     $this->assertContains($cookieValue, $this->_client->getLastRawRequest(), 'Request is expected to contain the entire cookie "keyname=raw_value"');
 }
Example #5
0
 /**
  * Make sure using an invalid cookie jar object throws an exception
  *
  */
 public function testSetInvalidCookies()
 {
     $this->setExpectedException('Zend\\Http\\Exception\\InvalidArgumentException', 'Invalid parameter type passed as Cookie');
     $this->_client->addCookie('cookie');
 }
Example #6
0
 /**
  * @expectedException Zend\Http\Exception\InvalidArgumentException
  */
 public function testIfNullValueCookiesThrowsException()
 {
     $client = new Client();
     $client->addCookie("test", null);
 }