diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2015-12-06 14:31:26 +0100 |
---|---|---|
committer | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2015-12-06 14:31:26 +0100 |
commit | a7f1921f7db312b5def3839393357f443dcbb52c (patch) | |
tree | 0522e03891433e9fdc9eb64d52b2d9651aadf1f7 /src/Wallabag/CoreBundle/Tests/Controller | |
parent | 2e15e30bf0e634bbbc3a9678904953d015490ed2 (diff) | |
parent | 752b90d1f2e279d3662d5431b09c7587df2937ca (diff) | |
download | wallabag-a7f1921f7db312b5def3839393357f443dcbb52c.tar.gz wallabag-a7f1921f7db312b5def3839393357f443dcbb52c.tar.zst wallabag-a7f1921f7db312b5def3839393357f443dcbb52c.zip |
Merge pull request #1478 from K-Phoen/rule-based-tags
Rule based tags
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php | 55 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | 38 |
2 files changed, 93 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php index 7085151a..7b32354f 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php | |||
@@ -479,4 +479,59 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
479 | $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text'))); | 479 | $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text'))); |
480 | $this->assertContains($expectedMessage, $alert[0]); | 480 | $this->assertContains($expectedMessage, $alert[0]); |
481 | } | 481 | } |
482 | |||
483 | public function testTaggingRuleCreation() | ||
484 | { | ||
485 | $this->logInAs('admin'); | ||
486 | $client = $this->getClient(); | ||
487 | |||
488 | $crawler = $client->request('GET', '/config'); | ||
489 | |||
490 | $this->assertTrue($client->getResponse()->isSuccessful()); | ||
491 | |||
492 | $form = $crawler->filter('button[id=tagging_rule_save]')->form(); | ||
493 | |||
494 | $data = array( | ||
495 | 'tagging_rule[rule]' => 'readingTime <= 3', | ||
496 | 'tagging_rule[tags]' => 'short reading', | ||
497 | ); | ||
498 | |||
499 | $client->submit($form, $data); | ||
500 | |||
501 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
502 | |||
503 | $crawler = $client->followRedirect(); | ||
504 | |||
505 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); | ||
506 | $this->assertContains('Tagging rules updated', $alert[0]); | ||
507 | |||
508 | $deleteLink = $crawler->filter('.delete')->last()->link(); | ||
509 | |||
510 | $crawler = $client->click($deleteLink); | ||
511 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
512 | |||
513 | $crawler = $client->followRedirect(); | ||
514 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); | ||
515 | $this->assertContains('Tagging rule deleted', $alert[0]); | ||
516 | } | ||
517 | |||
518 | public function dataForTaggingRuleFailed() | ||
519 | { | ||
520 | return array( | ||
521 | array( | ||
522 | array( | ||
523 | 'rss_config[rule]' => 'unknownVar <= 3', | ||
524 | 'rss_config[tags]' => 'cool tag', | ||
525 | ), | ||
526 | 'The variable « unknownVar » does not exist.', | ||
527 | ), | ||
528 | array( | ||
529 | array( | ||
530 | 'rss_config[rule]' => 'length(domainName) <= 42', | ||
531 | 'rss_config[tags]' => 'cool tag', | ||
532 | ), | ||
533 | 'The operator « length » does not exist.', | ||
534 | ), | ||
535 | ); | ||
536 | } | ||
482 | } | 537 | } |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 56b4c9e4..af62aee8 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | |||
@@ -102,6 +102,44 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
102 | $this->assertContains('Google', $alert[0]); | 102 | $this->assertContains('Google', $alert[0]); |
103 | } | 103 | } |
104 | 104 | ||
105 | /** | ||
106 | * This test will require an internet connection. | ||
107 | */ | ||
108 | public function testPostNewThatWillBeTaggued() | ||
109 | { | ||
110 | $this->logInAs('admin'); | ||
111 | $client = $this->getClient(); | ||
112 | |||
113 | $crawler = $client->request('GET', '/new'); | ||
114 | |||
115 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
116 | |||
117 | $form = $crawler->filter('button[type=submit]')->form(); | ||
118 | |||
119 | $data = array( | ||
120 | 'entry[url]' => $url = 'https://github.com/wallabag/wallabag', | ||
121 | ); | ||
122 | |||
123 | $client->submit($form, $data); | ||
124 | |||
125 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
126 | |||
127 | $crawler = $client->followRedirect(); | ||
128 | |||
129 | $em = $client->getContainer() | ||
130 | ->get('doctrine.orm.entity_manager'); | ||
131 | $entry = $em | ||
132 | ->getRepository('WallabagCoreBundle:Entry') | ||
133 | ->findOneByUrl($url); | ||
134 | $tags = $entry->getTags(); | ||
135 | |||
136 | $this->assertCount(1, $tags); | ||
137 | $this->assertEquals('wallabag', $tags[0]->getLabel()); | ||
138 | |||
139 | $em->remove($entry); | ||
140 | $em->flush(); | ||
141 | } | ||
142 | |||
105 | public function testArchive() | 143 | public function testArchive() |
106 | { | 144 | { |
107 | $this->logInAs('admin'); | 145 | $this->logInAs('admin'); |