/**
  * Add cookie
  *
  * @param   scriptlet.Cookie cookie
  * @return  scriptlet.Cookie added cookie
  */
 public function addCookie(Cookie $cookie)
 {
     $this->initCookies();
     $this->cookies[$cookie->getName()] = $cookie;
     return $cookie;
 }
Example #2
0
 /**
  * Navigate to a relative URL 
  *
  * @param   string relative
  * @param   string params
  * @throws  unittest.AssertionFailedError  
  */
 public function beginAt($relative, $params = null, $method = HttpConstants::GET)
 {
     $this->dom = $this->xpath = null;
     $this->conn->getUrl()->setPath($relative);
     try {
         $this->response = $this->doRequest($method, $params);
         // If we get a cookie, store it for this domain and reuse it in
         // subsequent requests. If cookies are used for sessioning, we
         // would be creating new sessions with every request otherwise!
         foreach ((array) $this->response->header('Set-Cookie') as $str) {
             $cookie = Cookie::parse($str);
             $this->cookies[$this->conn->getUrl()->getHost()][$cookie->getName()] = $cookie;
         }
     } catch (\lang\XPException $e) {
         $this->response = null;
         $this->fail($relative, $e, null);
     }
 }
 public function parseCookie()
 {
     $cookie = Cookie::parse('Bugzilla_logincookie=e9hR2sFvjX; path=/; expires=Fri, 01-Jan-2038 00:00:00 GMT; secure; HttpOnly');
     $this->assertHeaderEquals('Bugzilla_logincookie=e9hR2sFvjX; expires=Fri, 01-Jan-2038 00:00:00 GMT; path=/; secure; HTTPOnly', $cookie);
 }