From 567421af5019bf5937aa2b4214b405d87a1f1f86 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 10 Feb 2016 17:41:28 +0100 Subject: remove tag from entry #1377 --- .../Tests/Controller/TagControllerTest.php | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Tests') diff --git a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php index dc93dd6b..ae29a2a6 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php @@ -6,6 +6,8 @@ use Wallabag\CoreBundle\Tests\WallabagCoreTestCase; class TagControllerTest extends WallabagCoreTestCase { + public $tagName = 'opensource'; + public function testList() { $this->logInAs('admin'); @@ -31,7 +33,7 @@ class TagControllerTest extends WallabagCoreTestCase $form = $crawler->filter('button[id=tag_save]')->form(); $data = array( - 'tag[label]' => 'opensource', + 'tag[label]' => $this->tagName, ); $client->submit($form, $data); @@ -65,4 +67,28 @@ class TagControllerTest extends WallabagCoreTestCase $this->assertEquals(2, count($newEntry->getTags())); } + + public function testRemoveTagFromEntry() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $entry = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneByUsernameAndNotArchived('admin'); + + $tag = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Tag') + ->findOnebyEntryAndLabel($entry, $this->tagName); + + $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId()); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId()); + + $this->assertEquals(404, $client->getResponse()->getStatusCode()); + } } -- cgit v1.2.3 From e686a76d343a3745c3dfe8010d9e5784e56bb17c Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 10 Feb 2016 18:40:15 +0100 Subject: improve test and change method name. Also, display number of entries for each tag --- src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Tests') diff --git a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php index ae29a2a6..d6391282 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php @@ -81,12 +81,14 @@ class TagControllerTest extends WallabagCoreTestCase $tag = $client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Tag') - ->findOnebyEntryAndLabel($entry, $this->tagName); + ->findOneByEntryAndTagLabel($entry, $this->tagName); $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId()); $this->assertEquals(302, $client->getResponse()->getStatusCode()); + $this->assertNotContains($this->tagName, $entry->getTags()); + $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId()); $this->assertEquals(404, $client->getResponse()->getStatusCode()); -- cgit v1.2.3