aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php6
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php7
-rw-r--r--tests/Wallabag/CoreBundle/Controller/TagControllerTest.php31
3 files changed, 43 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
index b6514ea6..1cbc413d 100644
--- a/src/Wallabag/CoreBundle/Controller/TagController.php
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -105,7 +105,11 @@ class TagController extends Controller
105 */ 105 */
106 public function showEntriesForTagAction(Tag $tag, $page, Request $request) 106 public function showEntriesForTagAction(Tag $tag, $page, Request $request)
107 { 107 {
108 $pagerAdapter = new ArrayAdapter($tag->getEntries()->toArray()); 108 $entriesByTag = $this->getDoctrine()
109 ->getRepository('WallabagCoreBundle:Entry')
110 ->findAllByTagId($this->getUser()->getId(), $tag->getId());
111
112 $pagerAdapter = new ArrayAdapter($entriesByTag);
109 113
110 $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries') 114 $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')
111 ->prepare($pagerAdapter, $page); 115 ->prepare($pagerAdapter, $page);
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php
index 8553dced..09e99f36 100644
--- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php
+++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php
@@ -28,6 +28,13 @@ class LoadTagData extends AbstractFixture implements OrderedFixtureInterface
28 28
29 $this->addReference('bar-tag', $tag2); 29 $this->addReference('bar-tag', $tag2);
30 30
31 $tag3 = new Tag();
32 $tag3->setLabel('baz');
33
34 $manager->persist($tag3);
35
36 $this->addReference('baz-tag', $tag3);
37
31 $manager->flush(); 38 $manager->flush();
32 } 39 }
33 40
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
index 58450e5f..71652760 100644
--- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
@@ -131,4 +131,35 @@ class TagControllerTest extends WallabagCoreTestCase
131 131
132 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 132 $this->assertEquals(404, $client->getResponse()->getStatusCode());
133 } 133 }
134
135 public function testShowEntriesForTagAction()
136 {
137 $this->logInAs('admin');
138 $client = $this->getClient();
139
140 $entry = $client->getContainer()
141 ->get('doctrine.orm.entity_manager')
142 ->getRepository('WallabagCoreBundle:Entry')
143 ->findOneByUsernameAndNotArchived('admin');
144
145 $tag = $client->getContainer()
146 ->get('doctrine.orm.entity_manager')
147 ->getRepository('WallabagCoreBundle:Tag')
148 ->findOneByEntryAndTagLabel($entry, 'foo');
149
150 $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug());
151
152 $this->assertEquals(200, $client->getResponse()->getStatusCode());
153 $this->assertCount(2, $crawler->filter('div[class=entry]'));
154
155 $tag = $client->getContainer()
156 ->get('doctrine.orm.entity_manager')
157 ->getRepository('WallabagCoreBundle:Tag')
158 ->findOneByLabel('baz');
159
160 $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug());
161
162 $this->assertEquals(200, $client->getResponse()->getStatusCode());
163 $this->assertCount(0, $crawler->filter('div[class=entry]'));
164 }
134} 165}