Add for deleting rule from an other user

This commit is contained in:
Jeremy Benoist 2016-01-21 18:06:10 +01:00
parent 0f0e8eb82a
commit a3cac44c78

View 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());
}
}