diff options
Diffstat (limited to 'tests')
3 files changed, 66 insertions, 15 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index 7193f9b0..bb3ea9e2 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php | |||
@@ -56,8 +56,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
56 | 56 | ||
57 | $crawler = $client->followRedirect(); | 57 | $crawler = $client->followRedirect(); |
58 | 58 | ||
59 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text'])); | 59 | $this->assertContains('flashes.config.notice.config_saved', $crawler->filter('body')->extract(['_text'])[0]); |
60 | $this->assertContains('flashes.config.notice.config_saved', $alert[0]); | ||
61 | } | 60 | } |
62 | 61 | ||
63 | public function testChangeReadingSpeed() | 62 | public function testChangeReadingSpeed() |
@@ -213,8 +212,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
213 | 212 | ||
214 | $crawler = $client->followRedirect(); | 213 | $crawler = $client->followRedirect(); |
215 | 214 | ||
216 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text'])); | 215 | $this->assertContains('flashes.config.notice.password_updated', $crawler->filter('body')->extract(['_text'])[0]); |
217 | $this->assertContains('flashes.config.notice.password_updated', $alert[0]); | ||
218 | } | 216 | } |
219 | 217 | ||
220 | public function dataForUserFailed() | 218 | public function dataForUserFailed() |
@@ -382,8 +380,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
382 | 380 | ||
383 | $crawler = $client->followRedirect(); | 381 | $crawler = $client->followRedirect(); |
384 | 382 | ||
385 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text'])); | 383 | $this->assertContains('flashes.config.notice.user_added', $crawler->filter('body')->extract(['_text'])[0]); |
386 | $this->assertContains('flashes.config.notice.user_added', $alert[0]); | ||
387 | 384 | ||
388 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | 385 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); |
389 | $user = $em | 386 | $user = $em |
@@ -474,8 +471,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
474 | 471 | ||
475 | $crawler = $client->followRedirect(); | 472 | $crawler = $client->followRedirect(); |
476 | 473 | ||
477 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text'])); | 474 | $this->assertContains('flashes.config.notice.rss_updated', $crawler->filter('body')->extract(['_text'])[0]); |
478 | $this->assertContains('flashes.config.notice.rss_updated', $alert[0]); | ||
479 | } | 475 | } |
480 | 476 | ||
481 | public function dataForRssFailed() | 477 | public function dataForRssFailed() |
@@ -540,8 +536,32 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
540 | 536 | ||
541 | $crawler = $client->followRedirect(); | 537 | $crawler = $client->followRedirect(); |
542 | 538 | ||
543 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text'])); | 539 | $this->assertContains('flashes.config.notice.tagging_rules_updated', $crawler->filter('body')->extract(['_text'])[0]); |
544 | $this->assertContains('flashes.config.notice.tagging_rules_updated', $alert[0]); | 540 | |
541 | $editLink = $crawler->filter('.mode_edit')->last()->link(); | ||
542 | |||
543 | $crawler = $client->click($editLink); | ||
544 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
545 | $this->assertContains('?tagging-rule=', $client->getResponse()->headers->get('location')); | ||
546 | |||
547 | $crawler = $client->followRedirect(); | ||
548 | |||
549 | $form = $crawler->filter('button[id=tagging_rule_save]')->form(); | ||
550 | |||
551 | $data = [ | ||
552 | 'tagging_rule[rule]' => 'readingTime <= 30', | ||
553 | 'tagging_rule[tags]' => 'short reading', | ||
554 | ]; | ||
555 | |||
556 | $client->submit($form, $data); | ||
557 | |||
558 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
559 | |||
560 | $crawler = $client->followRedirect(); | ||
561 | |||
562 | $this->assertContains('flashes.config.notice.tagging_rules_updated', $crawler->filter('body')->extract(['_text'])[0]); | ||
563 | |||
564 | $this->assertContains('readingTime <= 30', $crawler->filter('body')->extract(['_text'])[0]); | ||
545 | 565 | ||
546 | $deleteLink = $crawler->filter('.delete')->last()->link(); | 566 | $deleteLink = $crawler->filter('.delete')->last()->link(); |
547 | 567 | ||
@@ -549,8 +569,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
549 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 569 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); |
550 | 570 | ||
551 | $crawler = $client->followRedirect(); | 571 | $crawler = $client->followRedirect(); |
552 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(['_text'])); | 572 | $this->assertContains('flashes.config.notice.tagging_rules_deleted', $crawler->filter('body')->extract(['_text'])[0]); |
553 | $this->assertContains('flashes.config.notice.tagging_rules_deleted', $alert[0]); | ||
554 | } | 573 | } |
555 | 574 | ||
556 | public function dataForTaggingRuleFailed() | 575 | public function dataForTaggingRuleFailed() |
@@ -613,7 +632,23 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
613 | ->getRepository('WallabagCoreBundle:TaggingRule') | 632 | ->getRepository('WallabagCoreBundle:TaggingRule') |
614 | ->findAll()[0]; | 633 | ->findAll()[0]; |
615 | 634 | ||
616 | $crawler = $client->request('GET', '/tagging-rule/delete/'.$rule->getId()); | 635 | $crawler = $client->request('GET', '/tagging-rule/edit/'.$rule->getId()); |
636 | |||
637 | $this->assertEquals(403, $client->getResponse()->getStatusCode()); | ||
638 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
639 | $this->assertContains('You can not access this tagging rule', $body[0]); | ||
640 | } | ||
641 | |||
642 | public function testEditingTaggingRuleFromAnOtherUser() | ||
643 | { | ||
644 | $this->logInAs('bob'); | ||
645 | $client = $this->getClient(); | ||
646 | |||
647 | $rule = $client->getContainer()->get('doctrine.orm.entity_manager') | ||
648 | ->getRepository('WallabagCoreBundle:TaggingRule') | ||
649 | ->findAll()[0]; | ||
650 | |||
651 | $crawler = $client->request('GET', '/tagging-rule/edit/'.$rule->getId()); | ||
617 | 652 | ||
618 | $this->assertEquals(403, $client->getResponse()->getStatusCode()); | 653 | $this->assertEquals(403, $client->getResponse()->getStatusCode()); |
619 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | 654 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 9942b2a0..c40e10a5 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -29,7 +29,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
29 | 29 | ||
30 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 30 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
31 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | 31 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
32 | $this->assertContains('quickstart.intro.paragraph_1', $body[0]); | 32 | $this->assertContains('quickstart.intro.title', $body[0]); |
33 | 33 | ||
34 | // Test if quickstart is disabled when user has 1 entry | 34 | // Test if quickstart is disabled when user has 1 entry |
35 | $crawler = $client->request('GET', '/new'); | 35 | $crawler = $client->request('GET', '/new'); |
diff --git a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php index 8ec2a75a..b1c8c946 100644 --- a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php +++ b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php | |||
@@ -8,7 +8,23 @@ class WallabagExtensionTest extends \PHPUnit_Framework_TestCase | |||
8 | { | 8 | { |
9 | public function testRemoveWww() | 9 | public function testRemoveWww() |
10 | { | 10 | { |
11 | $extension = new WallabagExtension(); | 11 | $entryRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') |
12 | ->disableOriginalConstructor() | ||
13 | ->getMock(); | ||
14 | |||
15 | $tagRepository = $this->getMockBuilder('Wallabag\CoreBundle\Repository\TagRepository') | ||
16 | ->disableOriginalConstructor() | ||
17 | ->getMock(); | ||
18 | |||
19 | $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface') | ||
20 | ->disableOriginalConstructor() | ||
21 | ->getMock(); | ||
22 | |||
23 | $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface') | ||
24 | ->disableOriginalConstructor() | ||
25 | ->getMock(); | ||
26 | |||
27 | $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator); | ||
12 | 28 | ||
13 | $this->assertEquals('lemonde.fr', $extension->removeWww('www.lemonde.fr')); | 29 | $this->assertEquals('lemonde.fr', $extension->removeWww('www.lemonde.fr')); |
14 | $this->assertEquals('lemonde.fr', $extension->removeWww('lemonde.fr')); | 30 | $this->assertEquals('lemonde.fr', $extension->removeWww('lemonde.fr')); |