diff options
Diffstat (limited to 'tests/Wallabag/ApiBundle')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 409a8291..0979ca93 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -4,6 +4,7 @@ namespace Tests\Wallabag\ApiBundle\Controller; | |||
4 | 4 | ||
5 | use Tests\Wallabag\ApiBundle\WallabagApiTestCase; | 5 | use Tests\Wallabag\ApiBundle\WallabagApiTestCase; |
6 | use Wallabag\CoreBundle\Entity\Tag; | 6 | use Wallabag\CoreBundle\Entity\Tag; |
7 | use Wallabag\CoreBundle\Helper\ContentProxy; | ||
7 | 8 | ||
8 | class EntryRestControllerTest extends WallabagApiTestCase | 9 | class EntryRestControllerTest extends WallabagApiTestCase |
9 | { | 10 | { |
@@ -359,6 +360,29 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
359 | $this->assertCount(2, $content['tags']); | 360 | $this->assertCount(2, $content['tags']); |
360 | } | 361 | } |
361 | 362 | ||
363 | public function testPostEntryWhenFetchContentFails() | ||
364 | { | ||
365 | /** @var \Symfony\Component\DependencyInjection\Container $container */ | ||
366 | $container = $this->client->getContainer(); | ||
367 | $contentProxy = $this->getMockBuilder(ContentProxy::class) | ||
368 | ->disableOriginalConstructor() | ||
369 | ->setMethods(['updateEntry']) | ||
370 | ->getMock(); | ||
371 | $contentProxy->expects($this->any()) | ||
372 | ->method('updateEntry') | ||
373 | ->willThrowException(new \Exception('Test Fetch content fails')); | ||
374 | $container->set('wallabag_core.content_proxy', $contentProxy); | ||
375 | |||
376 | $this->client->request('POST', '/api/entries.json', [ | ||
377 | 'url' => 'http://www.example.com/', | ||
378 | ]); | ||
379 | |||
380 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
381 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
382 | $this->assertGreaterThan(0, $content['id']); | ||
383 | $this->assertEquals('http://www.example.com/', $content['url']); | ||
384 | } | ||
385 | |||
362 | public function testPostArchivedAndStarredEntry() | 386 | public function testPostArchivedAndStarredEntry() |
363 | { | 387 | { |
364 | $this->client->request('POST', '/api/entries.json', [ | 388 | $this->client->request('POST', '/api/entries.json', [ |