+<?php
+require_once 'HTTP/Request2.php';
+require_once 'HTTP/Request2/Adapter/Mock.php';
+
+class Wrt3g_DummyRequest extends HTTP_Request2
+{
+ /**
+ * Maps request paths (i.e. "/index.php") to files containing the HTML body
+ *
+ * @var array
+ */
+ public static $mapping = array(
+ '/Status_NoAuth.asp' => 'tests/status_noauth-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
+ *
+ * @return HTTP_Request2_Response
+ *
+ * @throws HTTP_Request2_Exception When the path is not mapped, or
+ * the mapped file does not exist
+ */
+ public function 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();
+ }
+}
+
+?>
\ No newline at end of file