aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-10-01 16:47:48 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-01 16:52:05 +0200
commitbf3dc999e7b25888460faff2251f75e4a79491c4 (patch)
treee529f9a322f7359141254ed6f05cc2c15ba845c3 /tests
parentc4bf7af96f52aaafd13049e74f27b368eec79bf8 (diff)
downloadwallabag-bf3dc999e7b25888460faff2251f75e4a79491c4.tar.gz
wallabag-bf3dc999e7b25888460faff2251f75e4a79491c4.tar.zst
wallabag-bf3dc999e7b25888460faff2251f75e4a79491c4.zip
Add ability to edit a tagging rule
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php61
1 files changed, 48 insertions, 13 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']));