Example #1
0
 /**
  * Sets up this test case
  *
  * @return void
  */
 public function setUp()
 {
     self::$gogrid = new Server('foo', 'bar');
     self::$httpClientAdapterTest = new \Zend\Http\Client\Adapter\Test();
     self::$gogrid->getHttpClient()->setAdapter(self::$httpClientAdapterTest);
     $filename = __DIR__ . '/_files/' . $this->getName() . '.response';
     if (file_exists($filename)) {
         self::$httpClientAdapterTest->setResponse($this->loadResponse($filename));
     }
 }
Example #2
0
 public function setUp()
 {
     $options = array('base_url' => 'https://api.com/', 'api_version' => 'v1', 'timeout' => 10);
     $this->client = new Client($options);
     $adapter = new \Zend\Http\Client\Adapter\Test();
     $adapter->setResponse("HTTP/1.1 200 OK" . "\r\n" . "Status: 200 OK" . "\r\n" . "Content-Type: application/json; charset=utf-8" . "\r\n" . "\r\n" . '{' . '    "id": 1,' . '    "name": "EdpGithub",' . '}');
     $this->client->setHttpAdapter($adapter);
     $eventManager = new EventManager();
     $this->client->setEventManager($eventManager);
 }
Example #3
0
 /**
  * @group ZF-8330
  */
 public function testGetsFeedLinksAndNormalisesRelativeUrlsOnUriWithPath()
 {
     try {
         $currClient = Reader\Reader::getHttpClient();
         $response = new \Zend\Http\Response();
         $response->setContent('<!DOCTYPE html><html><head><link rel="alternate" type="application/rss+xml" href="../test.rss"><link rel="alternate" type="application/atom+xml" href="/test.atom"></head><body></body></html>');
         $response->setStatusCode(200);
         $testAdapter = new \Zend\Http\Client\Adapter\Test();
         $testAdapter->setResponse($response);
         Reader\Reader::setHttpClient(new \Zend\Http\Client(null, array('adapter' => $testAdapter)));
         $links = Reader\Reader::findFeedLinks('http://foo/bar');
         Reader\Reader::setHttpClient($currClient);
     } catch (\Exception $e) {
         $this->fail($e->getMessage());
     }
     $this->assertEquals('http://foo/test.rss', $links->rss);
     $this->assertEquals('http://foo/test.atom', $links->atom);
 }
 public function testDownloadAttachmentShouldNotCallInsertFileWhen404()
 {
     $filegallib = TikiLib::lib('filegal');
     $filegallib = $this->getMock('FileGalLib', array('insert_file'));
     $filegallib->expects($this->exactly(0))->method('insert_file');
     $adapter = new Zend\Http\Client\Adapter\Test();
     $adapter->setResponse("HTTP/1.1 404 NOT FOUND" . "\r\n" . "Content-type: image/jpg" . "\r\n" . "Content-length: 1034" . "\r\n" . "\r\n" . 'empty content');
     $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');
     $this->expectOutputString("\n\nImporting attachments:\nUnable to download attachment tadv2.jpg. Error message was: 404 NOT FOUND\nUnable to download attachment 1881232-hostelaria-las-torres-0.jpg. Error message was: 404 NOT FOUND\nUnable to download attachment 1881259-caminhando-no-gelo-no-vale-do-sil-ncio-0.jpg. Error message was: 404 NOT FOUND\n0 attachments imported and 3 errors.\n");
     $obj->downloadAttachments();
     $this->assertEquals(array(), $obj->newFiles);
 }