X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FTests%2FController%2FTagControllerTest.php;h=dc93dd6b8575a7b70ce9b66b99dd441c7d72913a;hb=da2240f9d409a8301a1d469823a265780e6f1b7b;hp=34faf70976e6a818bde71af0a9779fbdaded7e67;hpb=4919584b8758b23e127536b686776c1c41b3d215;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php index 34faf709..dc93dd6b 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php @@ -3,7 +3,6 @@ namespace Wallabag\CoreBundle\Tests\Controller; use Wallabag\CoreBundle\Tests\WallabagCoreTestCase; -use Doctrine\ORM\AbstractQuery; class TagControllerTest extends WallabagCoreTestCase { @@ -16,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') + ->findOneByUsernameAndNotArchived('admin'); + + $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') + ->find($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') + ->find($entry->getId()); + + $this->assertEquals(2, count($newEntry->getTags())); + } }