Zend_Http_Client_Adapter_Test can now fail on demand

In August I commited some code to Zend Framework that enabled the Zend_Http_Client_Adapter_Test component to fail on demand so that we could test a component in our framework at VG Nett with phpunit. The feature has been added to Zend Framework 1.10 and here is a small example on how you can use it:

// Instantiate a new adapter and client
$adapter = new Zend_Http_Client_Adapter_Test();
$client = new Zend_Http_Client('http://www.example.com', array(
    'adapter' => $adapter

// Force the next request to fail with an exception

try {
    // This call will result in a Zend_Http_Client_Adapter_Exception
} catch (Zend_Http_Client_Adapter_Exception $e) {
    // ...

// Further requests will work as expected until you call setNextRequestWillFail(true) again
This entry was posted in PHP, Technology and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s