class TagRestControllerTest extends WallabagApiTestCase
{
+ private $otherUserTagLabel = 'bob';
+
public function testGetUserTags()
{
$this->client->request('GET', '/api/tags.json');
$this->assertArrayHasKey('id', $content[0]);
$this->assertArrayHasKey('label', $content[0]);
+ $tagLabels = array_map(function ($i) {
+ return $i['label'];
+ }, $content);
+
+ $this->assertNotContains($this->otherUserTagLabel, $tagLabels, 'There is a possible tag leak');
+
return end($content);
}
$this->assertNull($tag, $tagLabel . ' was removed because it begun an orphan tag');
}
+ public function testDeleteOtherUserTag()
+ {
+ $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
+ $tag = $em->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($this->otherUserTagLabel);
+
+ $this->client->request('DELETE', '/api/tags/' . $tag->getId() . '.json');
+
+ $this->assertSame(404, $this->client->getResponse()->getStatusCode());
+ }
+
public function dataForDeletingTagByLabel()
{
return [
$this->assertSame(404, $this->client->getResponse()->getStatusCode());
}
+ public function testDeleteTagByLabelOtherUser()
+ {
+ $this->client->request('DELETE', '/api/tag/label.json', ['tag' => $this->otherUserTagLabel]);
+
+ $this->assertSame(404, $this->client->getResponse()->getStatusCode());
+ }
+
/**
* @dataProvider dataForDeletingTagByLabel
*/
$this->assertSame(404, $this->client->getResponse()->getStatusCode());
}
+
+ public function testDeleteTagsByLabelOtherUser()
+ {
+ $this->client->request('DELETE', '/api/tags/label.json', ['tags' => $this->otherUserTagLabel]);
+
+ $this->assertSame(404, $this->client->getResponse()->getStatusCode());
+ }
}