diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2017-05-19 11:25:19 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2017-05-19 11:25:19 +0200 |
commit | 4ab0d25f652bdfe184046be6d50afd594709e1a9 (patch) | |
tree | 0a9ea39836619df4b97d4b12bb6a0384e8c2a5ee /tests | |
parent | 21f78f4d4baae7afaa5845317a9cb52e031f1d1a (diff) | |
parent | f87e6547e8c49a2fe4bd21ec185e99464d4d957e (diff) | |
download | wallabag-4ab0d25f652bdfe184046be6d50afd594709e1a9.tar.gz wallabag-4ab0d25f652bdfe184046be6d50afd594709e1a9.tar.zst wallabag-4ab0d25f652bdfe184046be6d50afd594709e1a9.zip |
Merge remote-tracking branch 'origin/master' into 2.3
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 34 | ||||
-rw-r--r-- | tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | 20 |
2 files changed, 54 insertions, 0 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 4f49f040..bf7d373a 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 | { |
@@ -375,6 +376,39 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
375 | $this->assertCount(3, $content['tags']); | 376 | $this->assertCount(3, $content['tags']); |
376 | } | 377 | } |
377 | 378 | ||
379 | public function testPostEntryWhenFetchContentFails() | ||
380 | { | ||
381 | /** @var \Symfony\Component\DependencyInjection\Container $container */ | ||
382 | $container = $this->client->getContainer(); | ||
383 | $contentProxy = $this->getMockBuilder(ContentProxy::class) | ||
384 | ->disableOriginalConstructor() | ||
385 | ->setMethods(['updateEntry']) | ||
386 | ->getMock(); | ||
387 | $contentProxy->expects($this->any()) | ||
388 | ->method('updateEntry') | ||
389 | ->willThrowException(new \Exception('Test Fetch content fails')); | ||
390 | $container->set('wallabag_core.content_proxy', $contentProxy); | ||
391 | |||
392 | try { | ||
393 | $this->client->request('POST', '/api/entries.json', [ | ||
394 | 'url' => 'http://www.example.com/', | ||
395 | ]); | ||
396 | |||
397 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
398 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
399 | $this->assertGreaterThan(0, $content['id']); | ||
400 | $this->assertEquals('http://www.example.com/', $content['url']); | ||
401 | } finally { | ||
402 | // Remove the created entry to avoid side effects on other tests | ||
403 | if (isset($content['id'])) { | ||
404 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | ||
405 | $entry = $em->getReference('WallabagCoreBundle:Entry', $content['id']); | ||
406 | $em->remove($entry); | ||
407 | $em->flush(); | ||
408 | } | ||
409 | } | ||
410 | } | ||
411 | |||
378 | public function testPostArchivedAndStarredEntry() | 412 | public function testPostArchivedAndStarredEntry() |
379 | { | 413 | { |
380 | $this->client->request('POST', '/api/entries.json', [ | 414 | $this->client->request('POST', '/api/entries.json', [ |
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 698e5e13..19c8698e 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -627,6 +627,26 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
627 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | 627 | $this->assertCount(1, $crawler->filter('div[class=entry]')); |
628 | } | 628 | } |
629 | 629 | ||
630 | public function testFilterOnReadingTimeWithNegativeValue() | ||
631 | { | ||
632 | $this->logInAs('admin'); | ||
633 | $client = $this->getClient(); | ||
634 | |||
635 | $crawler = $client->request('GET', '/unread/list'); | ||
636 | |||
637 | $form = $crawler->filter('button[id=submit-filter]')->form(); | ||
638 | |||
639 | $data = [ | ||
640 | 'entry_filter[readingTime][right_number]' => -22, | ||
641 | 'entry_filter[readingTime][left_number]' => -22, | ||
642 | ]; | ||
643 | |||
644 | $crawler = $client->submit($form, $data); | ||
645 | |||
646 | // forcing negative value results in no entry displayed | ||
647 | $this->assertCount(0, $crawler->filter('div[class=entry]')); | ||
648 | } | ||
649 | |||
630 | public function testFilterOnReadingTimeOnlyUpper() | 650 | public function testFilterOnReadingTimeOnlyUpper() |
631 | { | 651 | { |
632 | $this->logInAs('admin'); | 652 | $this->logInAs('admin'); |