diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php | 50 |
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 | } |