From: Jeremy Benoist Date: Fri, 19 May 2017 09:25:19 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/master' into 2.3 X-Git-Tag: 2.3.0~31^2~91 X-Git-Url: https://git.immae.eu/?p=github%2Fwallabag%2Fwallabag.git;a=commitdiff_plain;h=4ab0d25f652bdfe184046be6d50afd594709e1a9 Merge remote-tracking branch 'origin/master' into 2.3 --- 4ab0d25f652bdfe184046be6d50afd594709e1a9 diff --cc tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 4f49f040,0a65f9ce..bf7d373a --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php @@@ -372,9 -373,42 +373,42 @@@ class EntryRestControllerTest extends W $this->assertEquals('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']); $this->assertEquals(true, $content['is_archived']); $this->assertEquals(false, $content['is_starred']); - $this->assertCount(2, $content['tags']); + $this->assertCount(3, $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', [