Exemple #1
0
 /**
  *
  * this method fixes the following
  *
  * @see \Behat\Mink\Driver\BrowserKitDriver::getCookie
  *   Note that the following doesn't work well because
  *   Symfony\Component\BrowserKit\CookieJar stores cookies by name,
  *   path, AND domain and if you don't fill them all in correctly then
  *   you won't get the value that you're expecting.
  *
  *
  *
  * @param string $name
  * @return null|string
  */
 private function parseCookieFromHeaders($name)
 {
     try {
         $headers = $this->session->getResponseHeaders();
     } catch (\Behat\Mink\Exception\UnsupportedDriverActionException $e) {
         return null;
     }
     if (!is_array($headers) || empty($headers) || !isset($headers['set-cookie'])) {
         return null;
     }
     foreach ($headers['set-cookie'] as $cookieString) {
         if (!(stripos($cookieString, $name . '=') === 0)) {
             continue;
         }
         $cookiePieces = explode(';', $cookieString);
         if (!$cookiePieces) {
             return null;
         }
         $cookieKeyValue = explode('=', $cookiePieces[0]);
         if (!isset($cookieKeyValue[1])) {
             return null;
         }
         return $cookieKeyValue[1];
     }
     return null;
 }
Exemple #2
0
 public function _getResponseHeader($header)
 {
     $headers = $this->session->getResponseHeaders();
     if (!isset($headers[$header])) {
         return false;
     }
     return $headers[$header];
 }
 public function testGetResponseHeaders()
 {
     $this->driver->expects($this->once())->method('getResponseHeaders')->will($this->returnValue($ret = array(2, 3, 4)));
     $this->assertEquals($ret, $this->session->getResponseHeaders());
 }
 /**
  * @param Session $session
  *
  * @return string|null
  */
 private function getResponseHeadersLogMessage(Session $session)
 {
     try {
         return 'Response headers:' . "\n" . print_r($session->getResponseHeaders(), true) . "\n";
     } catch (MinkException $exception) {
         return null;
     }
 }