aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2015-08-22 12:56:42 +0200
committerJeremy Benoist <j0k3r@users.noreply.github.com>2015-08-22 12:56:42 +0200
commitec00964de22a338d8f814c5440f8e09f542fdbbf (patch)
tree4dc70780d5b8278825f423d247b8486a52f7d265 /src/Wallabag/CoreBundle/Tests
parentf9d5155abf1bc63fae91043a5e4c73ac3a4f0ba9 (diff)
parent7244d6cb61912b80341595c56cc22d9bb56e6251 (diff)
downloadwallabag-ec00964de22a338d8f814c5440f8e09f542fdbbf.tar.gz
wallabag-ec00964de22a338d8f814c5440f8e09f542fdbbf.tar.zst
wallabag-ec00964de22a338d8f814c5440f8e09f542fdbbf.zip
Merge pull request #1372 from wallabag/v2-assign-tags
assign tags to an entry
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests')
-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}