diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-02 16:53:52 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-07 07:43:48 +0200 |
commit | 74e1f7433a5fc0a9bbf3942a22917e0dd1cc6923 (patch) | |
tree | 0e40afc2a85658705fdf4a1a6b8e7c6c3d7dfbc3 /tests/Wallabag/CoreBundle/Controller | |
parent | 6c8806cadc9894e2bc7d067055feea6ee2b7602c (diff) | |
download | wallabag-74e1f7433a5fc0a9bbf3942a22917e0dd1cc6923.tar.gz wallabag-74e1f7433a5fc0a9bbf3942a22917e0dd1cc6923.tar.zst wallabag-74e1f7433a5fc0a9bbf3942a22917e0dd1cc6923.zip |
Fix tag test
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller')
-rw-r--r-- | tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php | 2 | ||||
-rw-r--r-- | tests/Wallabag/CoreBundle/Controller/TagControllerTest.php | 26 |
2 files changed, 16 insertions, 12 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php index 9f35a448..9ecd8bc4 100644 --- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php | |||
@@ -193,7 +193,7 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
193 | $contentInDB = $client->getContainer() | 193 | $contentInDB = $client->getContainer() |
194 | ->get('doctrine.orm.entity_manager') | 194 | ->get('doctrine.orm.entity_manager') |
195 | ->getRepository('WallabagCoreBundle:Entry') | 195 | ->getRepository('WallabagCoreBundle:Entry') |
196 | ->findOneByUsernameAndNotArchived('admin'); | 196 | ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId()); |
197 | 197 | ||
198 | ob_start(); | 198 | ob_start(); |
199 | $crawler = $client->request('GET', '/export/'.$contentInDB->getId().'.json'); | 199 | $crawler = $client->request('GET', '/export/'.$contentInDB->getId().'.json'); |
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php index 2c32393f..86a6cca2 100644 --- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php | |||
@@ -26,7 +26,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
26 | $entry = $client->getContainer() | 26 | $entry = $client->getContainer() |
27 | ->get('doctrine.orm.entity_manager') | 27 | ->get('doctrine.orm.entity_manager') |
28 | ->getRepository('WallabagCoreBundle:Entry') | 28 | ->getRepository('WallabagCoreBundle:Entry') |
29 | ->findOneByUsernameAndNotArchived('admin'); | 29 | ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId()); |
30 | 30 | ||
31 | $crawler = $client->request('GET', '/view/'.$entry->getId()); | 31 | $crawler = $client->request('GET', '/view/'.$entry->getId()); |
32 | 32 | ||
@@ -43,9 +43,9 @@ class TagControllerTest extends WallabagCoreTestCase | |||
43 | $entry = $client->getContainer() | 43 | $entry = $client->getContainer() |
44 | ->get('doctrine.orm.entity_manager') | 44 | ->get('doctrine.orm.entity_manager') |
45 | ->getRepository('WallabagCoreBundle:Entry') | 45 | ->getRepository('WallabagCoreBundle:Entry') |
46 | ->findOneByUsernameAndNotArchived('admin'); | 46 | ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId()); |
47 | 47 | ||
48 | $this->assertEquals(1, count($entry->getTags())); | 48 | $this->assertEquals(3, count($entry->getTags())); |
49 | 49 | ||
50 | // tag already exists and already assigned | 50 | // tag already exists and already assigned |
51 | $client->submit($form, $data); | 51 | $client->submit($form, $data); |
@@ -56,7 +56,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
56 | ->getRepository('WallabagCoreBundle:Entry') | 56 | ->getRepository('WallabagCoreBundle:Entry') |
57 | ->find($entry->getId()); | 57 | ->find($entry->getId()); |
58 | 58 | ||
59 | $this->assertEquals(1, count($newEntry->getTags())); | 59 | $this->assertEquals(3, count($newEntry->getTags())); |
60 | 60 | ||
61 | // tag already exists but still not assigned to this entry | 61 | // tag already exists but still not assigned to this entry |
62 | $data = [ | 62 | $data = [ |
@@ -71,7 +71,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
71 | ->getRepository('WallabagCoreBundle:Entry') | 71 | ->getRepository('WallabagCoreBundle:Entry') |
72 | ->find($entry->getId()); | 72 | ->find($entry->getId()); |
73 | 73 | ||
74 | $this->assertEquals(2, count($newEntry->getTags())); | 74 | $this->assertEquals(3, count($newEntry->getTags())); |
75 | } | 75 | } |
76 | 76 | ||
77 | public function testAddMultipleTagToEntry() | 77 | public function testAddMultipleTagToEntry() |
@@ -82,7 +82,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
82 | $entry = $client->getContainer() | 82 | $entry = $client->getContainer() |
83 | ->get('doctrine.orm.entity_manager') | 83 | ->get('doctrine.orm.entity_manager') |
84 | ->getRepository('WallabagCoreBundle:Entry') | 84 | ->getRepository('WallabagCoreBundle:Entry') |
85 | ->findOneByUsernameAndNotArchived('admin'); | 85 | ->findByUrlAndUserId('http://0.0.0.0/entry2', $this->getLoggedInUserId()); |
86 | 86 | ||
87 | $crawler = $client->request('GET', '/view/'.$entry->getId()); | 87 | $crawler = $client->request('GET', '/view/'.$entry->getId()); |
88 | 88 | ||
@@ -101,9 +101,13 @@ class TagControllerTest extends WallabagCoreTestCase | |||
101 | ->find($entry->getId()); | 101 | ->find($entry->getId()); |
102 | 102 | ||
103 | $tags = $newEntry->getTags()->toArray(); | 103 | $tags = $newEntry->getTags()->toArray(); |
104 | foreach ($tags as $key => $tag) { | ||
105 | $tags[$key] = $tag->getLabel(); | ||
106 | } | ||
107 | |||
104 | $this->assertGreaterThanOrEqual(2, count($tags)); | 108 | $this->assertGreaterThanOrEqual(2, count($tags)); |
105 | $this->assertNotEquals(false, array_search('foo2', $tags), 'Tag foo2 is assigned to the entry'); | 109 | $this->assertNotFalse(array_search('foo2', $tags), 'Tag foo2 is assigned to the entry'); |
106 | $this->assertNotEquals(false, array_search('bar2', $tags), 'Tag bar2 is assigned to the entry'); | 110 | $this->assertNotFalse(array_search('bar2', $tags), 'Tag bar2 is assigned to the entry'); |
107 | } | 111 | } |
108 | 112 | ||
109 | public function testRemoveTagFromEntry() | 113 | public function testRemoveTagFromEntry() |
@@ -114,7 +118,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
114 | $entry = $client->getContainer() | 118 | $entry = $client->getContainer() |
115 | ->get('doctrine.orm.entity_manager') | 119 | ->get('doctrine.orm.entity_manager') |
116 | ->getRepository('WallabagCoreBundle:Entry') | 120 | ->getRepository('WallabagCoreBundle:Entry') |
117 | ->findOneByUsernameAndNotArchived('admin'); | 121 | ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId()); |
118 | 122 | ||
119 | $tag = $client->getContainer() | 123 | $tag = $client->getContainer() |
120 | ->get('doctrine.orm.entity_manager') | 124 | ->get('doctrine.orm.entity_manager') |
@@ -140,7 +144,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
140 | $entry = $client->getContainer() | 144 | $entry = $client->getContainer() |
141 | ->get('doctrine.orm.entity_manager') | 145 | ->get('doctrine.orm.entity_manager') |
142 | ->getRepository('WallabagCoreBundle:Entry') | 146 | ->getRepository('WallabagCoreBundle:Entry') |
143 | ->findOneByUsernameAndNotArchived('admin'); | 147 | ->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getLoggedInUserId()); |
144 | 148 | ||
145 | $tag = $client->getContainer() | 149 | $tag = $client->getContainer() |
146 | ->get('doctrine.orm.entity_manager') | 150 | ->get('doctrine.orm.entity_manager') |
@@ -160,6 +164,6 @@ class TagControllerTest extends WallabagCoreTestCase | |||
160 | $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug()); | 164 | $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug()); |
161 | 165 | ||
162 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 166 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
163 | $this->assertCount(0, $crawler->filter('div[class=entry]')); | 167 | $this->assertCount(1, $crawler->filter('div[class=entry]')); |
164 | } | 168 | } |
165 | } | 169 | } |