'tests/status_noauth-connected.htm', '/index_wstatus1.asp' => 'tests/index_wstatus1-connected-excellent.htm', '/index_wstatus2.asp' => 'tests/index_wstatus2-connected.htm' ); /** * Sets the mock connection adapter * * @param string|Net_Url2 Request URL * @param string Request method * @param array Configuration for this Request instance */ public function __construct( $url = null, $method = self::METHOD_GET, array $config = array() ) { parent::__construct($url, $method, $config); $this->setAdapter(new HTTP_Request2_Adapter_Mock()); } /** * Sends the request and returns the response. * When the host is three-letter numeric string, it * is used as HTTP response status code. No "proper" content * is returned in that case. * * @return HTTP_Request2_Response * * @throws HTTP_Request2_Exception When the path is not mapped, or * the mapped file does not exist */ public function send() { $host = $this->url->getHost(); if (strlen($host) == 3 && is_numeric($host)) { $this->adapter->addResponse( "HTTP/1.0 $host dummy\n\nnothing" ); return parent::send(); } $path = $this->url->getPath(); if (!isset(self::$mapping[$path])) { throw new HTTP_Request2_Exception( 'No predefined response for path: ' . $path ); } $file = dirname(__FILE__) . '/../' . self::$mapping[$path]; if (!file_exists($file)) { throw new HTTP_Request2_Exception( 'Response file does not exist: ' . $file ); } $this->adapter->addResponse( "HTTP/1.0 200 OK\n" . "\n" . file_get_contents($file) ); return parent::send(); } } ?>