X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FApiBundle%2FController%2FTagRestControllerTest.php;h=7f69bd67ca985f4008d0219582088a422014c5a4;hb=7ab5eb9508921d84b4b4ec84a59135d536da748e;hp=90b132ebecbf4600c1d341d6f7027ad76cfbffca;hpb=4423b88c5b2c2d530b0a83a822f521a61ca4d4b8;p=github%2Fwallabag%2Fwallabag.git 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 return end($content); } - /** - * @depends testGetUserTags - */ - public function testDeleteUserTag($tag) + public function testDeleteUserTag() { - $tagName = $tag['label']; + $tagLabel = 'tagtest'; + $tag = new Tag(); + $tag->setLabel($tagLabel); + + $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); + $em->persist($tag); + $em->flush(); + $em->clear(); - $this->client->request('DELETE', '/api/tags/'.$tag['id'].'.json'); + $this->client->request('DELETE', '/api/tags/'.$tag->getId().'.json'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); $this->assertArrayHasKey('label', $content); - $this->assertEquals($tag['label'], $content['label']); - $this->assertEquals($tag['slug'], $content['slug']); + $this->assertEquals($tag->getLabel(), $content['label']); + $this->assertEquals($tag->getSlug(), $content['slug']); - $entries = $this->client->getContainer() - ->get('doctrine.orm.entity_manager') - ->getRepository('WallabagCoreBundle:Entry') - ->findAllByTagId($this->user->getId(), $tag['id']); + $entries = $em->getRepository('WallabagCoreBundle:Entry') + ->findAllByTagId($this->user->getId(), $tag->getId()); $this->assertCount(0, $entries); - $tag = $this->client->getContainer() - ->get('doctrine.orm.entity_manager') - ->getRepository('WallabagCoreBundle:Tag') - ->findOneByLabel($tagName); + $tag = $em->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($tagLabel); - $this->assertNull($tag, $tagName.' was removed because it begun an orphan tag'); + $this->assertNull($tag, $tagLabel.' was removed because it begun an orphan tag'); } public function dataForDeletingTagByLabel()