X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FTests%2FController%2FTagControllerTest.php;h=d25b2db5fbeb4bd0432d323661a93e4cfd7eb3aa;hb=d4ebe5c5dcf581416ab76136908cafbde78f63bf;hp=4a43e04928124d1718673936d1322019e9d5932c;hpb=8ce32af61229eec8f4cc34b207273d47f60adc48;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php index 4a43e049..d25b2db5 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php @@ -15,4 +15,54 @@ class TagControllerTest extends WallabagCoreTestCase $this->assertEquals(200, $client->getResponse()->getStatusCode()); } + + public function testAddTagToEntry() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $entry = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneBy(array()); + + $crawler = $client->request('GET', '/view/'.$entry->getId()); + + $form = $crawler->filter('button[id=tag_save]')->form(); + + $data = array( + 'tag[label]' => 'opensource', + ); + + $client->submit($form, $data); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $this->assertEquals(1, count($entry->getTags())); + + # tag already exists and already assigned + $client->submit($form, $data); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $newEntry = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneById($entry->getId()); + + $this->assertEquals(1, count($newEntry->getTags())); + + # tag already exists but still not assigned to this entry + $data = array( + 'tag[label]' => 'foo', + ); + + $client->submit($form, $data); + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $newEntry = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneById($entry->getId()); + + $this->assertEquals(2, count($newEntry->getTags())); + } }