We use Varien_Http_Client to create HTTP requests from the Magento extension, for example:
public function callApi(β¦) { <SNIP> // Set default factory adapter to socket in case curl isn't installed. $client = new Varien_Http_Client($apiUri, array( 'adapter' => 'Zend_Http_Client_Adapter_Socket', 'timeout' => $timeout, )); $client->setRawData($xmlDoc->saveXML())->setEncType('text/xml'); $response = $client->request($method); $results = ''; if ($response->isSuccessful()) { $results = $response->getBody(); } return $results; }
I understand that I should avoid checking the internal components of Varien_Http_Client ; rather, I have to verify that we send him the correct inputs and correctly process his outputs. I can make fun of Varien_Http_Client quite easily, but even if I reorganize this code so that I replace Varien_Http_Client with my layout, I donβt understand how to verify that the constructor was called with the expected arguments, since the constructor is called PHPUnit::getMock .
I do not need the layout of the object; I need a dummy class. How can I verify that the constructor was called with the expected arguments?
* (In this case, I know ways to get around this Varien_Http_Client specific Varien_Http_Client , but what can I do with more opaque third-party code?)
source share