From 8a99c7a86b138faee5dc92ab6ecbd281dbd19451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Gomez?= Date: Sat, 31 Oct 2015 16:21:56 +0100 Subject: Add a few functional tests for the tagging rules creation form --- .../Tests/Controller/ConfigControllerTest.php | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php index 7085151a..4eb67ffd 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 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text'))); $this->assertContains($expectedMessage, $alert[0]); } + + public function testTaggingRuleCreation() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/config'); + + $this->assertTrue($client->getResponse()->isSuccessful()); + + $form = $crawler->filter('button[id=tagging_rule_save]')->form(); + + $data = array( + 'tagging_rule[rule]' => 'readingTime <= 3', + 'tagging_rule[tags]' => 'short reading', + ); + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); + $this->assertContains('Tagging rules updated', $alert[0]); + + $deleteLink = $crawler->filter('.delete')->eq(0)->link(); + + $crawler = $client->click($deleteLink); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); + $this->assertContains('Tagging rule deleted', $alert[0]); + } + + public function dataForTaggingRuleFailed() + { + return array( + array( + array( + 'rss_config[rule]' => 'unknownVar <= 3', + 'rss_config[tags]' => 'cool tag', + ), + 'The variable « unknownVar » does not exist.', + ), + array( + array( + 'rss_config[rule]' => 'length(domainName) <= 42', + 'rss_config[tags]' => 'cool tag', + ), + 'The operator « length » does not exist.', + ), + ); + } } -- cgit v1.2.3