diff options
author | adev <adev2000@gmail.com> | 2017-05-15 20:47:59 +0200 |
---|---|---|
committer | adev <adev2000@gmail.com> | 2017-05-31 16:03:54 +0200 |
commit | 7ab5eb9508921d84b4b4ec84a59135d536da748e (patch) | |
tree | 725d9fae04d07a2c0aec2d2f5a19e1b43ec7a5d1 /tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php | |
parent | 4423b88c5b2c2d530b0a83a822f521a61ca4d4b8 (diff) | |
download | wallabag-7ab5eb9508921d84b4b4ec84a59135d536da748e.tar.gz wallabag-7ab5eb9508921d84b4b4ec84a59135d536da748e.tar.zst wallabag-7ab5eb9508921d84b4b4ec84a59135d536da748e.zip |
Isolated tests
Use https://github.com/dmaicher/doctrine-test-bundle to have test isolation.
Diffstat (limited to 'tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php | 33 |
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() |