|
|
@@ -72,6 +72,13 @@ class Zend_Http_Client_Adapter_Test implements Zend_Http_Client_Adapter_Interfac
|
|
|
protected $responseIndex = 0;
|
|
|
|
|
|
/**
|
|
|
+ * Wether or not the next request will fail with an exception
|
|
|
+ *
|
|
|
+ * @var boolean
|
|
|
+ */
|
|
|
+ protected $_nextRequestWillFail = false;
|
|
|
+
|
|
|
+ /**
|
|
|
* Adapter constructor, currently empty. Config is set using setConfig()
|
|
|
*
|
|
|
*/
|
|
|
@@ -79,6 +86,19 @@ class Zend_Http_Client_Adapter_Test implements Zend_Http_Client_Adapter_Interfac
|
|
|
{ }
|
|
|
|
|
|
/**
|
|
|
+ * Set the nextRequestWillFail flag
|
|
|
+ *
|
|
|
+ * @param boolean $flag
|
|
|
+ * @return Zend_Http_Client_Adapter_Test
|
|
|
+ */
|
|
|
+ public function setNextRequestWillFail($flag)
|
|
|
+ {
|
|
|
+ $this->_nextRequestWillFail = (bool) $flag;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Set the configuration array for the adapter
|
|
|
*
|
|
|
* @param Zend_Config | array $config
|
|
|
@@ -108,9 +128,16 @@ class Zend_Http_Client_Adapter_Test implements Zend_Http_Client_Adapter_Interfac
|
|
|
* @param int $port
|
|
|
* @param boolean $secure
|
|
|
* @param int $timeout
|
|
|
+ * @throws Zend_Http_Client_Adapter_Exception
|
|
|
*/
|
|
|
public function connect($host, $port = 80, $secure = false)
|
|
|
- { }
|
|
|
+ {
|
|
|
+ if ($this->_nextRequestWillFail) {
|
|
|
+ $this->_nextRequestWillFail = false;
|
|
|
+ require_once 'Zend/Http/Client/Adapter/Exception.php';
|
|
|
+ throw new Zend_Http_Client_Adapter_Exception('Request failed');
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Send request to the remote server
|