aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authoradev <adev2000@gmail.com>2017-05-08 12:35:02 +0200
committeradev <adev2000@gmail.com>2017-05-08 14:57:25 +0200
commit08f29ae7b6af585f3af1dd2f8b01854fb0985668 (patch)
tree859985863551dcaf699a5b32a8e8d4afc45e7a78 /tests
parentf2beee5185e0bf7f983fb97a34480b4c74d7eb8c (diff)
downloadwallabag-08f29ae7b6af585f3af1dd2f8b01854fb0985668.tar.gz
wallabag-08f29ae7b6af585f3af1dd2f8b01854fb0985668.tar.zst
wallabag-08f29ae7b6af585f3af1dd2f8b01854fb0985668.zip
Create a new entry via API even when its content can't be retrieved
Fix #2988
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php24
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
5use Tests\Wallabag\ApiBundle\WallabagApiTestCase; 5use Tests\Wallabag\ApiBundle\WallabagApiTestCase;
6use Wallabag\CoreBundle\Entity\Tag; 6use Wallabag\CoreBundle\Entity\Tag;
7use Wallabag\CoreBundle\Helper\ContentProxy;
7 8
8class EntryRestControllerTest extends WallabagApiTestCase 9class 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', [