Esempio n. 1
0
 /**
  * Navigate to a given URL
  *
  * @param   string target
  * @param   string params
  * @param   string method
  * @throws  unittest.AssertionFailedError  
  */
 public function navigateTo($target, $params = null, $method = HttpConstants::GET)
 {
     if (strstr($target, '://')) {
         $url = new \peer\URL($target);
         $this->conn = $this->getConnection(sprintf('%s://%s%s/', $url->getScheme(), $url->getHost(), -1 === $url->getPort(-1) ? '' : ':' . $url->getPort()));
         $params ? $url->setParams($params) : '';
         $this->beginAt($url->getPath(), $url->getParams(), $method);
     } else {
         if ('' !== $target && '/' === $target[0]) {
             $this->beginAt($target, $params, $method);
         } else {
             $base = $this->getBase();
             $this->beginAt(substr($base, 0, strrpos($base, '/')) . '/' . $target, $params, $method);
         }
     }
 }
 public function doCreate()
 {
     $req = $this->newRequest('GET', new \peer\URL('http://localhost/'));
     $res = new \scriptlet\HttpScriptletResponse();
     $s = newinstance('scriptlet.xml.XMLScriptlet', array(), '{
   public function needsSession($request) { return TRUE; }
 }');
     $s->service($req, $res);
     $this->assertEquals(\peer\http\HttpConstants::STATUS_FOUND, $res->statusCode);
     // Check URL from Location: header contains the session ID
     with($redirect = new \peer\URL(substr($res->headers[0], strlen('Location: '))));
     $this->assertEquals('http', $redirect->getScheme());
     $this->assertEquals('localhost', $redirect->getHost());
     $this->assertEquals(sprintf('/xml/psessionid=%s/static', session_id()), $redirect->getPath());
     $this->assertEquals(array(), $redirect->getParams(), $redirect->getURL());
 }