1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-08-01 17:38:38 +00:00

Create a new entry via API even when its content can't be retrieved

Fix #2988
This commit is contained in:
adev 2017-05-08 12:35:02 +02:00
parent f2beee5185
commit 08f29ae7b6
2 changed files with 37 additions and 4 deletions

View file

@ -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
{
@ -359,6 +360,29 @@ 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);
$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']);
}
public function testPostArchivedAndStarredEntry()
{
$this->client->request('POST', '/api/entries.json', [