function testGetRequestWithoutIncidentGivesNoErrors()
 {
     $url = new SimpleUrl('http://*****:*****@this.com/page.html');
     $url->addRequestParameters(array('a' => 'A', 'b' => 'B'));
     $agent =& new MockRequestUserAgent();
     $agent->setReturnReference('_createHttpRequest', $this->_request);
     $agent->SimpleUserAgent();
     $response =& $agent->fetchResponse(new SimpleUrl('http://*****:*****@this.com/page.html'), new SimpleGetEncoding(array('a' => 'A', 'b' => 'B')));
     $this->assertFalse($response->isError());
 }
 /**
  *    Turns an incoming URL string into a
  *    URL object, filling the relative URL if
  *    a base URL is present.
  *    @param string $base_url       Browser current URL.
  *    @param string $raw_url        Incoming URL.
  *    @param hash $parameters       Additional request, parameters.
  *    @return SimpleUrl             Absolute URL.
  *    @access public
  *    @static
  */
 function createAbsoluteUrl($base_url, $raw_url, $parameters = false)
 {
     $url = new SimpleUrl($raw_url);
     if ($parameters) {
         $url->addRequestParameters($parameters);
     }
     $url->makeAbsolute($base_url);
     return $url;
 }
Beispiel #3
0
 function testHead()
 {
     $headers =& new MockSimpleHttpHeaders($this);
     $headers->setReturnValue('getMimeType', 'text/html');
     $headers->setReturnValue('getResponseCode', 200);
     $headers->setReturnValue('getNewCookies', array());
     $response =& new MockSimpleHttpResponse($this);
     $response->setReturnValue('getContent', 'stuff');
     $response->setReturnReference('getHeaders', $headers);
     $request =& new MockSimpleHttpRequest($this);
     $request->setReturnReference('fetch', $response);
     $url = new SimpleUrl('http://this.com/page.html');
     $url->addRequestParameters(array('a' => 'A', 'b' => 'B'));
     $agent =& new MockRequestUserAgent($this);
     $agent->setReturnReference('_createHttpRequest', $request);
     $agent->expectOnce('_createHttpRequest', array('HEAD', new SimpleUrl('http://*****:*****@this.com/page.html?a=A&b=B'), array()));
     $agent->SimpleUserAgent();
     $agent->fetchResponse('HEAD', new SimpleUrl('http://*****:*****@this.com/page.html'), array('a' => 'A', 'b' => 'B'));
     $agent->tally();
 }
Beispiel #4
0
 /**
  *    Builds the appropriate HTTP request object.
  *    @param string $method       Fetching method.
  *    @param SimpleUrl $url       Target to fetch as url object.
  *    @param hash $parameters     POST/GET parameters.
  *    @return SimpleHttpRequest   New request object.
  *    @access protected
  */
 function &_createHttpRequest($method, $url, $parameters)
 {
     if ($method == 'POST') {
         $request =& new SimpleHttpPostRequest($url, $parameters);
         return $request;
     }
     if ($parameters) {
         $url->addRequestParameters($parameters);
     }
     return new SimpleHttpRequest($url, $method);
 }
 function _testHead()
 {
     $headers =& new MockSimpleHttpHeaders($this);
     $headers->setReturnValue('getMimeType', 'text/html');
     $headers->setReturnValue('getResponseCode', 200);
     $headers->setReturnValue('getNewCookies', array());
     $response =& new MockSimpleHttpResponse($this);
     $response->setReturnValue("getContent", "stuff");
     $request =& new MockSimpleHttpRequest($this);
     $request->setReturnReference('fetch', $response);
     $url = new SimpleUrl("http://this.com/page.html");
     $url->addRequestParameters(array("a" => "A", "b" => "B"));
     $agent =& new MockRequestUserAgent($this);
     $agent->setReturnReference('_createRequest', $request);
     $agent->expectOnce('_createRequest', array('HEAD', $url, array("a" => "A", "b" => "B")));
     $agent->SimpleUserAgent();
     $agent->fetchResponse('HEAD', 'http://this.com/page.html', array("a" => "A", "b" => "B"));
     $agent->tally();
 }
Beispiel #6
0
 function testHead()
 {
     $headers =& new MockSimpleHttpHeaders($this);
     $headers->setReturnValue('getMimeType', 'text/html');
     $headers->setReturnValue('getResponseCode', 200);
     $headers->setReturnValue('getNewCookies', array());
     $response =& new MockSimpleHttpResponse($this);
     $response->setReturnValue('getContent', 'stuff');
     $response->setReturnReference('getHeaders', $headers);
     $request =& new MockSimpleHttpRequest($this);
     $request->setReturnReference('fetch', $response);
     $url = new SimpleUrl('http://this.com/page.html');
     $url->addRequestParameters(array('a' => 'A', 'b' => 'B'));
     $agent =& new MockRequestUserAgent($this);
     $agent->setReturnReference('_createHttpRequest', $request);
     $agent->SimpleUserAgent();
     $agent->fetchResponse('HEAD', 'http://this.com/page.html', array('a' => 'A', 'b' => 'B'));
     $this->assertIdentical($agent->getCurrentUrl(), false);
     $this->assertIdentical($agent->getCurrentMethod(), false);
     $this->assertEqual($agent->getCurrentPostData(), false);
     $agent->tally();
 }