X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FApiBundle%2FController%2FEntryRestControllerTest.php;h=0a65f9cee0628a78a38ab6b2fd7ce259c1383371;hb=91ba9a59754b09f0713161567d36c959c2aa5ffe;hp=63d70bd9bb3b1c2ef51f59a6e1c05921e0cd4c88;hpb=a2ae05a61ca7aad476a48247a4559c25dd55618d;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 63d70bd9..0a65f9ce 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php @@ -4,6 +4,7 @@ namespace Tests\Wallabag\ApiBundle\Controller; use Tests\Wallabag\ApiBundle\WallabagApiTestCase; use Wallabag\CoreBundle\Entity\Tag; +use Wallabag\CoreBundle\Helper\ContentProxy; class EntryRestControllerTest extends WallabagApiTestCase { @@ -375,6 +376,39 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertCount(2, $content['tags']); } + public function testPostEntryWhenFetchContentFails() + { + /** @var \Symfony\Component\DependencyInjection\Container $container */ + $container = $this->client->getContainer(); + $contentProxy = $this->getMockBuilder(ContentProxy::class) + ->disableOriginalConstructor() + ->setMethods(['updateEntry']) + ->getMock(); + $contentProxy->expects($this->any()) + ->method('updateEntry') + ->willThrowException(new \Exception('Test Fetch content fails')); + $container->set('wallabag_core.content_proxy', $contentProxy); + + try { + $this->client->request('POST', '/api/entries.json', [ + 'url' => 'http://www.example.com/', + ]); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + $content = json_decode($this->client->getResponse()->getContent(), true); + $this->assertGreaterThan(0, $content['id']); + $this->assertEquals('http://www.example.com/', $content['url']); + } finally { + // Remove the created entry to avoid side effects on other tests + if (isset($content['id'])) { + $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); + $entry = $em->getReference('WallabagCoreBundle:Entry', $content['id']); + $em->remove($entry); + $em->flush(); + } + } + } + public function testPostArchivedAndStarredEntry() { $this->client->request('POST', '/api/entries.json', [