*\r
* LICENSE:\r
*\r
- * Copyright (c) 2008, 2009, Alexey Borzov <avb@php.net>\r
+ * Copyright (c) 2008-2011, Alexey Borzov <avb@php.net>\r
* All rights reserved.\r
*\r
* Redistribution and use in source and binary forms, with or without\r
* @package HTTP_Request2\r
* @author Alexey Borzov <avb@php.net>\r
* @license http://opensource.org/licenses/bsd-license.php New BSD License\r
- * @version CVS: $Id: Mock.php 274406 2009-01-23 18:01:57Z avb $\r
+ * @version SVN: $Id: Mock.php 308322 2011-02-14 13:58:03Z avb $\r
* @link http://pear.php.net/package/HTTP_Request2\r
*/\r
\r
* <code>\r
* $mock = new HTTP_Request2_Adapter_Mock();\r
* $mock->addResponse("HTTP/1.1 ... ");\r
- * \r
+ *\r
* $request = new HTTP_Request2();\r
* $request->setAdapter($mock);\r
- * \r
+ *\r
* // This will return the response set above\r
* $response = $req->send();\r
- * </code> \r
+ * </code>\r
*\r
* @category HTTP\r
* @package HTTP_Request2\r
* @author Alexey Borzov <avb@php.net>\r
- * @version Release: 0.4.1\r
+ * @version Release: 2.0.0RC1\r
*/\r
class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter\r
{\r
/**\r
* A queue of responses to be returned by sendRequest()\r
- * @var array \r
+ * @var array\r
*/\r
protected $responses = array();\r
\r
/**\r
* Returns the next response from the queue built by addResponse()\r
*\r
- * If the queue is empty will return default empty response with status 400,\r
+ * If the queue is empty it will return default empty response with status 400,\r
* if an Exception object was added to the queue it will be thrown.\r
*\r
* @param HTTP_Request2\r
if ($response instanceof HTTP_Request2_Response) {\r
return $response;\r
} else {\r
- // rethrow the exception,\r
+ // rethrow the exception\r
$class = get_class($response);\r
$message = $response->getMessage();\r
$code = $response->getCode();\r
* Adds response to the queue\r
*\r
* @param mixed either a string, a pointer to an open file,\r
- * a HTTP_Request2_Response or Exception object\r
+ * an instance of HTTP_Request2_Response or Exception\r
* @throws HTTP_Request2_Exception\r
*/\r
public function addResponse($response)\r
public static function createResponseFromString($str)\r
{\r
$parts = preg_split('!(\r?\n){2}!m', $str, 2);\r
- $headerLines = explode("\n", $parts[0]); \r
+ $headerLines = explode("\n", $parts[0]);\r
$response = new HTTP_Request2_Response(array_shift($headerLines));\r
foreach ($headerLines as $headerLine) {\r
$response->parseHeaderLine($headerLine);\r