aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2015-08-19 11:46:21 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2015-08-22 12:40:48 +0200
commit7244d6cb61912b80341595c56cc22d9bb56e6251 (patch)
treefdb958dd7a798ec52c013edd75df9e4233c08934 /src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php
parent109d67dbb16478f927c3d6a46ab61ea9994aafae (diff)
downloadwallabag-7244d6cb61912b80341595c56cc22d9bb56e6251.tar.gz
wallabag-7244d6cb61912b80341595c56cc22d9bb56e6251.tar.zst
wallabag-7244d6cb61912b80341595c56cc22d9bb56e6251.zip
assign tags to an entry
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php
index 4a43e049..af39d6ce 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
15 15
16 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 16 $this->assertEquals(200, $client->getResponse()->getStatusCode());
17 } 17 }
18
19 public function testAddTagToEntry()
20 {
21 $this->logInAs('admin');
22 $client = $this->getClient();
23
24 $entry = $client->getContainer()
25 ->get('doctrine.orm.entity_manager')
26 ->getRepository('WallabagCoreBundle:Entry')
27 ->findOneByIsArchived(false);
28
29 $crawler = $client->request('GET', '/view/'.$entry->getId());
30
31 $form = $crawler->filter('button[id=tag_save]')->form();
32
33 $data = array(
34 'tag[label]' => 'opensource',
35 );
36
37 $client->submit($form, $data);
38 $this->assertEquals(302, $client->getResponse()->getStatusCode());
39
40 $this->assertEquals(1, count($entry->getTags()));
41
42 # tag already exists and already assigned
43 $client->submit($form, $data);
44 $this->assertEquals(302, $client->getResponse()->getStatusCode());
45
46 $newEntry = $client->getContainer()
47 ->get('doctrine.orm.entity_manager')
48 ->getRepository('WallabagCoreBundle:Entry')
49 ->findOneById($entry->getId());
50
51 $this->assertEquals(1, count($newEntry->getTags()));
52
53 # tag already exists but still not assigned to this entry
54 $data = array(
55 'tag[label]' => 'foo',
56 );
57
58 $client->submit($form, $data);
59 $this->assertEquals(302, $client->getResponse()->getStatusCode());
60
61 $newEntry = $client->getContainer()
62 ->get('doctrine.orm.entity_manager')
63 ->getRepository('WallabagCoreBundle:Entry')
64 ->findOneById($entry->getId());
65
66 $this->assertEquals(2, count($newEntry->getTags()));
67 }
18} 68}