]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
Add tests for tag list routes
[github/wallabag/wallabag.git] / tests / Wallabag / CoreBundle / Controller / TagControllerTest.php
index 58450e5fb0933632480e8a7c60e6c30a20efc7a3..71652760d8a592c2729147ff4691527d1c819d3b 100644 (file)
@@ -131,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]'));
+    }
 }