aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2017-06-01 07:58:17 +0200
committerGitHub <noreply@github.com>2017-06-01 07:58:17 +0200
commit2a0eec07a5630401a9ceb7add65604f79238f10c (patch)
treebab2f2f763d4dca9f273a8ec1848f5da6c03ed20 /tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php
parent757ec837bea7f57dcefb71b3b90c66299ed6a922 (diff)
parent7ab5eb9508921d84b4b4ec84a59135d536da748e (diff)
downloadwallabag-2a0eec07a5630401a9ceb7add65604f79238f10c.tar.gz
wallabag-2a0eec07a5630401a9ceb7add65604f79238f10c.tar.zst
wallabag-2a0eec07a5630401a9ceb7add65604f79238f10c.zip
Merge pull request #3137 from aaa2000/isolated-tests
Isolated tests
Diffstat (limited to 'tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php33
1 files changed, 16 insertions, 17 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php
index 90b132eb..7f69bd67 100644
--- a/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php
@@ -22,36 +22,35 @@ class TagRestControllerTest extends WallabagApiTestCase
22 return end($content); 22 return end($content);
23 } 23 }
24 24
25 /** 25 public function testDeleteUserTag()
26 * @depends testGetUserTags
27 */
28 public function testDeleteUserTag($tag)
29 { 26 {
30 $tagName = $tag['label']; 27 $tagLabel = 'tagtest';
28 $tag = new Tag();
29 $tag->setLabel($tagLabel);
30
31 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
32 $em->persist($tag);
33 $em->flush();
34 $em->clear();
31 35
32 $this->client->request('DELETE', '/api/tags/'.$tag['id'].'.json'); 36 $this->client->request('DELETE', '/api/tags/'.$tag->getId().'.json');
33 37
34 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 38 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
35 39
36 $content = json_decode($this->client->getResponse()->getContent(), true); 40 $content = json_decode($this->client->getResponse()->getContent(), true);
37 41
38 $this->assertArrayHasKey('label', $content); 42 $this->assertArrayHasKey('label', $content);
39 $this->assertEquals($tag['label'], $content['label']); 43 $this->assertEquals($tag->getLabel(), $content['label']);
40 $this->assertEquals($tag['slug'], $content['slug']); 44 $this->assertEquals($tag->getSlug(), $content['slug']);
41 45
42 $entries = $this->client->getContainer() 46 $entries = $em->getRepository('WallabagCoreBundle:Entry')
43 ->get('doctrine.orm.entity_manager') 47 ->findAllByTagId($this->user->getId(), $tag->getId());
44 ->getRepository('WallabagCoreBundle:Entry')
45 ->findAllByTagId($this->user->getId(), $tag['id']);
46 48
47 $this->assertCount(0, $entries); 49 $this->assertCount(0, $entries);
48 50
49 $tag = $this->client->getContainer() 51 $tag = $em->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($tagLabel);
50 ->get('doctrine.orm.entity_manager')
51 ->getRepository('WallabagCoreBundle:Tag')
52 ->findOneByLabel($tagName);
53 52
54 $this->assertNull($tag, $tagName.' was removed because it begun an orphan tag'); 53 $this->assertNull($tag, $tagLabel.' was removed because it begun an orphan tag');
55 } 54 }
56 55
57 public function dataForDeletingTagByLabel() 56 public function dataForDeletingTagByLabel()