public function testFailRequestOnDemand() { $this->adapter->setNextRequestWillFail(true); try { // Make a connection that will fail $this->adapter->connect('http://foo'); $this->fail(); } catch (\Zend\Http\Client\Adapter\Exception $e) { // Connect again to see that the next request does not fail $this->adapter->connect('http://foo'); } }
public function testDownloadAttachmentShouldNotCallInsertFileWhenZendHttpClientFails() { global $filegallib; require_once 'lib/filegals/filegallib.php'; $filegallib = $this->getMock('FileGalLib', array('insert_file')); $filegallib->expects($this->exactly(0))->method('insert_file'); $adapter = new Zend_Http_Client_Adapter_Test(); $adapter->setNextRequestWillFail(true); $client = new Zend_Http_Client(); $client->setAdapter($adapter); $obj = $this->getMock('TikiImporter_Blog_Wordpress', array('getHttpClient', 'createFileGallery')); $obj->expects($this->once())->method('createFileGallery')->will($this->returnValue(1)); $obj->expects($this->once())->method('getHttpClient')->will($this->returnValue($client)); $obj->dom = new DOMDocument(); $obj->dom->load(dirname(__FILE__) . '/fixtures/wordpress_attachments.xml'); $obj->downloadAttachments(); $this->assertEquals(array(), $obj->newFiles); }
/** * @expectedException Zend_Gdata_App_HttpException */ public function testGetAuthSubTokenInfoCatchesHttpClientException() { $adapter = new Zend_Http_Client_Adapter_Test(); $adapter->setNextRequestWillFail(true); $client = new Zend_Gdata_HttpClient(); $client->setUri('http://example.com/AuthSub'); $client->setAdapter($adapter); $revoked = Zend_Gdata_AuthSub::getAuthSubTokenInfo($this->token, $client); }
public function testNewsshortActionFail() { $adapter = new Zend_Http_Client_Adapter_Test(); $adapter->setNextRequestWillFail(true); Zend_Feed::setHttpClient(new Zend_Http_Client(null, array('adapter' => $adapter))); $this->dispatch('/index/newsshort'); $this->assertController('index'); $this->assertAction('newsshort'); $this->assertQuery('p.messagebox.warning'); }