]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Add for deleting rule from an other user
authorJeremy Benoist <jeremy.benoist@gmail.com>
Thu, 21 Jan 2016 17:06:10 +0000 (18:06 +0100)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Fri, 22 Jan 2016 07:01:17 +0000 (08:01 +0100)
src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php

index 89ca31e2942b3f2288fe5f703d016174953ba9db..c8807425aa031bcc82ee6cbf19aa6efb949b4552 100644 (file)
@@ -520,18 +520,61 @@ class ConfigControllerTest extends WallabagCoreTestCase
         return array(
             array(
                 array(
-                    'rss_config[rule]' => 'unknownVar <= 3',
-                    'rss_config[tags]' => 'cool tag',
+                    'tagging_rule[rule]' => 'unknownVar <= 3',
+                    'tagging_rule[tags]' => 'cool tag',
+                ),
+                array(
+                    'The variable',
+                    'does not exist.',
                 ),
-                'The variable « unknownVar » does not exist.',
             ),
             array(
                 array(
-                    'rss_config[rule]' => 'length(domainName) <= 42',
-                    'rss_config[tags]' => 'cool tag',
+                    'tagging_rule[rule]' => 'length(domainName) <= 42',
+                    'tagging_rule[tags]' => 'cool tag',
+                ),
+                array(
+                    'The operator',
+                    'does not exist.',
                 ),
-                'The operator « length » does not exist.',
             ),
         );
     }
+
+    /**
+     * @dataProvider dataForTaggingRuleFailed
+     */
+    public function testTaggingRuleCreationFail($data, $messages)
+    {
+        $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();
+
+        $client->submit($form, $data);
+
+        $this->assertEquals(200, $client->getResponse()->getStatusCode());
+
+        foreach ($messages as $message) {
+            $this->assertContains($message, $client->getResponse()->getContent());
+        }
+    }
+
+    public function testDeletingTaggingRuleFromAnOtherUser()
+    {
+        $this->logInAs('bob');
+        $client = $this->getClient();
+
+        $rule = $client->getContainer()->get('doctrine.orm.entity_manager')
+            ->getRepository('WallabagCoreBundle:TaggingRule')
+            ->findAll()[0];
+
+        $client->request('GET', '/tagging-rule/delete/'.$rule->getId());
+        $this->assertEquals(403, $client->getResponse()->getStatusCode());
+        $this->assertContains('You can not access this tagging ryle', $client->getResponse()->getContent());
+    }
 }