X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FCoreBundle%2FController%2FTagControllerTest.php;h=71652760d8a592c2729147ff4691527d1c819d3b;hb=92fa168344c51cd1c5835678e649b05cb7a2d030;hp=a019d36c98c24cfb20882cd4d0e0f7e8f010fe81;hpb=d37bb05c881bfdbeb1144b327edd4dcc2cbb163f;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php index a019d36c..71652760 100644 --- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php @@ -39,6 +39,12 @@ class TagControllerTest extends WallabagCoreTestCase $client->submit($form, $data); $this->assertEquals(302, $client->getResponse()->getStatusCode()); + // be sure to reload the entry + $entry = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneByUsernameAndNotArchived('admin'); + $this->assertEquals(1, count($entry->getTags())); # tag already exists and already assigned @@ -125,4 +131,35 @@ class TagControllerTest extends WallabagCoreTestCase $this->assertEquals(404, $client->getResponse()->getStatusCode()); } + + public function testShowEntriesForTagAction() + { + $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') + ->findOneByEntryAndTagLabel($entry, 'foo'); + + $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug()); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertCount(2, $crawler->filter('div[class=entry]')); + + $tag = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Tag') + ->findOneByLabel('baz'); + + $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug()); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertCount(0, $crawler->filter('div[class=entry]')); + } }