diff options
Diffstat (limited to 'tests/Wallabag')
6 files changed, 116 insertions, 65 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php index fd72b8f2..5dcb3e00 100644 --- a/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php | |||
@@ -561,6 +561,8 @@ class WallabagRestControllerTest extends WallabagApiTestCase | |||
561 | */ | 561 | */ |
562 | public function testDeleteUserTag($tag) | 562 | public function testDeleteUserTag($tag) |
563 | { | 563 | { |
564 | $tagName = $tag['label']; | ||
565 | |||
564 | $this->client->request('DELETE', '/api/tags/'.$tag['id'].'.json'); | 566 | $this->client->request('DELETE', '/api/tags/'.$tag['id'].'.json'); |
565 | 567 | ||
566 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | 568 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); |
@@ -577,6 +579,13 @@ class WallabagRestControllerTest extends WallabagApiTestCase | |||
577 | ->findAllByTagId($this->user->getId(), $tag['id']); | 579 | ->findAllByTagId($this->user->getId(), $tag['id']); |
578 | 580 | ||
579 | $this->assertCount(0, $entries); | 581 | $this->assertCount(0, $entries); |
582 | |||
583 | $tag = $this->client->getContainer() | ||
584 | ->get('doctrine.orm.entity_manager') | ||
585 | ->getRepository('WallabagCoreBundle:Tag') | ||
586 | ->findOneByLabel($tagName); | ||
587 | |||
588 | $this->assertNull($tag, $tagName.' was removed because it begun an orphan tag'); | ||
580 | } | 589 | } |
581 | 590 | ||
582 | public function testDeleteTagByLabel() | 591 | public function testDeleteTagByLabel() |
@@ -794,6 +803,22 @@ class WallabagRestControllerTest extends WallabagApiTestCase | |||
794 | $this->assertEquals(true, $content['exists']); | 803 | $this->assertEquals(true, $content['exists']); |
795 | } | 804 | } |
796 | 805 | ||
806 | public function testGetEntriesExistsWithManyUrls() | ||
807 | { | ||
808 | $url1 = 'http://0.0.0.0/entry2'; | ||
809 | $url2 = 'http://0.0.0.0/entry10'; | ||
810 | $this->client->request('GET', '/api/entries/exists?urls[]='.$url1.'&urls[]='.$url2); | ||
811 | |||
812 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
813 | |||
814 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
815 | |||
816 | $this->assertArrayHasKey($url1, $content); | ||
817 | $this->assertArrayHasKey($url2, $content); | ||
818 | $this->assertEquals(true, $content[$url1]); | ||
819 | $this->assertEquals(false, $content[$url2]); | ||
820 | } | ||
821 | |||
797 | public function testGetEntriesExistsWhichDoesNotExists() | 822 | public function testGetEntriesExistsWhichDoesNotExists() |
798 | { | 823 | { |
799 | $this->client->request('GET', '/api/entries/exists?url=http://google.com/entry2'); | 824 | $this->client->request('GET', '/api/entries/exists?url=http://google.com/entry2'); |
@@ -804,4 +829,11 @@ class WallabagRestControllerTest extends WallabagApiTestCase | |||
804 | 829 | ||
805 | $this->assertEquals(false, $content['exists']); | 830 | $this->assertEquals(false, $content['exists']); |
806 | } | 831 | } |
832 | |||
833 | public function testGetEntriesExistsWithNoUrl() | ||
834 | { | ||
835 | $this->client->request('GET', '/api/entries/exists?url='); | ||
836 | |||
837 | $this->assertEquals(403, $this->client->getResponse()->getStatusCode()); | ||
838 | } | ||
807 | } | 839 | } |
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index c40e10a5..9b03a519 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -341,22 +341,23 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
341 | $this->logInAs('admin'); | 341 | $this->logInAs('admin'); |
342 | $client = $this->getClient(); | 342 | $client = $this->getClient(); |
343 | 343 | ||
344 | $content = $client->getContainer() | 344 | $em = $client->getContainer() |
345 | ->get('doctrine.orm.entity_manager') | 345 | ->get('doctrine.orm.entity_manager'); |
346 | |||
347 | $content = $em | ||
346 | ->getRepository('WallabagCoreBundle:Entry') | 348 | ->getRepository('WallabagCoreBundle:Entry') |
347 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | 349 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
348 | 350 | ||
349 | // empty content | 351 | // empty content |
350 | $content->setContent(''); | 352 | $content->setContent(''); |
351 | $client->getContainer()->get('doctrine.orm.entity_manager')->persist($content); | 353 | $em->persist($content); |
352 | $client->getContainer()->get('doctrine.orm.entity_manager')->flush(); | 354 | $em->flush(); |
353 | 355 | ||
354 | $client->request('GET', '/reload/'.$content->getId()); | 356 | $client->request('GET', '/reload/'.$content->getId()); |
355 | 357 | ||
356 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 358 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); |
357 | 359 | ||
358 | $content = $client->getContainer() | 360 | $content = $em |
359 | ->get('doctrine.orm.entity_manager') | ||
360 | ->getRepository('WallabagCoreBundle:Entry') | 361 | ->getRepository('WallabagCoreBundle:Entry') |
361 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | 362 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
362 | 363 | ||
@@ -486,9 +487,11 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
486 | $this->logInAs('admin'); | 487 | $this->logInAs('admin'); |
487 | $client = $this->getClient(); | 488 | $client = $this->getClient(); |
488 | 489 | ||
490 | $em = $client->getContainer() | ||
491 | ->get('doctrine.orm.entity_manager'); | ||
492 | |||
489 | // add a new content to be removed later | 493 | // add a new content to be removed later |
490 | $user = $client->getContainer() | 494 | $user = $em |
491 | ->get('doctrine.orm.entity_manager') | ||
492 | ->getRepository('WallabagUserBundle:User') | 495 | ->getRepository('WallabagUserBundle:User') |
493 | ->findOneByUserName('admin'); | 496 | ->findOneByUserName('admin'); |
494 | 497 | ||
@@ -502,12 +505,8 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
502 | $content->setArchived(true); | 505 | $content->setArchived(true); |
503 | $content->setLanguage('fr'); | 506 | $content->setLanguage('fr'); |
504 | 507 | ||
505 | $client->getContainer() | 508 | $em->persist($content); |
506 | ->get('doctrine.orm.entity_manager') | 509 | $em->flush(); |
507 | ->persist($content); | ||
508 | $client->getContainer() | ||
509 | ->get('doctrine.orm.entity_manager') | ||
510 | ->flush(); | ||
511 | 510 | ||
512 | $client->request('GET', '/view/'.$content->getId()); | 511 | $client->request('GET', '/view/'.$content->getId()); |
513 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 512 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
@@ -753,7 +752,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
753 | $this->assertCount(2, $crawler->filter('div[class=entry]')); | 752 | $this->assertCount(2, $crawler->filter('div[class=entry]')); |
754 | } | 753 | } |
755 | 754 | ||
756 | public function testCache() | 755 | public function testShareEntryPublicly() |
757 | { | 756 | { |
758 | $this->logInAs('admin'); | 757 | $this->logInAs('admin'); |
759 | $client = $this->getClient(); | 758 | $client = $this->getClient(); |
@@ -778,6 +777,10 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
778 | $this->assertContains('public', $client->getResponse()->headers->get('cache-control')); | 777 | $this->assertContains('public', $client->getResponse()->headers->get('cache-control')); |
779 | $this->assertContains('s-maxage=25200', $client->getResponse()->headers->get('cache-control')); | 778 | $this->assertContains('s-maxage=25200', $client->getResponse()->headers->get('cache-control')); |
780 | $this->assertNotContains('no-cache', $client->getResponse()->headers->get('cache-control')); | 779 | $this->assertNotContains('no-cache', $client->getResponse()->headers->get('cache-control')); |
780 | $this->assertContains('og:title', $client->getResponse()->getContent()); | ||
781 | $this->assertContains('og:type', $client->getResponse()->getContent()); | ||
782 | $this->assertContains('og:url', $client->getResponse()->getContent()); | ||
783 | $this->assertContains('og:image', $client->getResponse()->getContent()); | ||
781 | 784 | ||
782 | // sharing is now disabled | 785 | // sharing is now disabled |
783 | $client->getContainer()->get('craue_config')->set('share_public', 0); | 786 | $client->getContainer()->get('craue_config')->set('share_public', 0); |
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php index 47b86117..9ecd8bc4 100644 --- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php | |||
@@ -146,7 +146,9 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
146 | ->get('doctrine.orm.entity_manager') | 146 | ->get('doctrine.orm.entity_manager') |
147 | ->getRepository('WallabagCoreBundle:Entry') | 147 | ->getRepository('WallabagCoreBundle:Entry') |
148 | ->createQueryBuilder('e') | 148 | ->createQueryBuilder('e') |
149 | ->select('e, t') | ||
149 | ->leftJoin('e.user', 'u') | 150 | ->leftJoin('e.user', 'u') |
151 | ->leftJoin('e.tags', 't') | ||
150 | ->where('u.username = :username')->setParameter('username', 'admin') | 152 | ->where('u.username = :username')->setParameter('username', 'admin') |
151 | ->andWhere('e.isArchived = true') | 153 | ->andWhere('e.isArchived = true') |
152 | ->getQuery() | 154 | ->getQuery() |
@@ -169,6 +171,18 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
169 | // +1 for title line | 171 | // +1 for title line |
170 | $this->assertEquals(count($contentInDB) + 1, count($csv)); | 172 | $this->assertEquals(count($contentInDB) + 1, count($csv)); |
171 | $this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); | 173 | $this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); |
174 | $this->assertContains($contentInDB[0]['title'], $csv[1]); | ||
175 | $this->assertContains($contentInDB[0]['url'], $csv[1]); | ||
176 | $this->assertContains($contentInDB[0]['content'], $csv[1]); | ||
177 | $this->assertContains($contentInDB[0]['mimetype'], $csv[1]); | ||
178 | $this->assertContains($contentInDB[0]['language'], $csv[1]); | ||
179 | $this->assertContains($contentInDB[0]['createdAt']->format('d/m/Y h:i:s'), $csv[1]); | ||
180 | |||
181 | $expectedTag = []; | ||
182 | foreach ($contentInDB[0]['tags'] as $tag) { | ||
183 | $expectedTag[] = $tag['label']; | ||
184 | } | ||
185 | $this->assertContains(implode(', ', $expectedTag), $csv[1]); | ||
172 | } | 186 | } |
173 | 187 | ||
174 | public function testJsonExport() | 188 | public function testJsonExport() |
@@ -176,29 +190,23 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
176 | $this->logInAs('admin'); | 190 | $this->logInAs('admin'); |
177 | $client = $this->getClient(); | 191 | $client = $this->getClient(); |
178 | 192 | ||
179 | // to be sure results are the same | ||
180 | $contentInDB = $client->getContainer() | 193 | $contentInDB = $client->getContainer() |
181 | ->get('doctrine.orm.entity_manager') | 194 | ->get('doctrine.orm.entity_manager') |
182 | ->getRepository('WallabagCoreBundle:Entry') | 195 | ->getRepository('WallabagCoreBundle:Entry') |
183 | ->createQueryBuilder('e') | 196 | ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId()); |
184 | ->leftJoin('e.user', 'u') | ||
185 | ->where('u.username = :username')->setParameter('username', 'admin') | ||
186 | ->getQuery() | ||
187 | ->getArrayResult(); | ||
188 | 197 | ||
189 | ob_start(); | 198 | ob_start(); |
190 | $crawler = $client->request('GET', '/export/all.json'); | 199 | $crawler = $client->request('GET', '/export/'.$contentInDB->getId().'.json'); |
191 | ob_end_clean(); | 200 | ob_end_clean(); |
192 | 201 | ||
193 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 202 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
194 | 203 | ||
195 | $headers = $client->getResponse()->headers; | 204 | $headers = $client->getResponse()->headers; |
196 | $this->assertEquals('application/json', $headers->get('content-type')); | 205 | $this->assertEquals('application/json', $headers->get('content-type')); |
197 | $this->assertEquals('attachment; filename="All articles.json"', $headers->get('content-disposition')); | 206 | $this->assertEquals('attachment; filename="'.$contentInDB->getTitle().'.json"', $headers->get('content-disposition')); |
198 | $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding')); | 207 | $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding')); |
199 | 208 | ||
200 | $content = json_decode($client->getResponse()->getContent(), true); | 209 | $content = json_decode($client->getResponse()->getContent(), true); |
201 | $this->assertEquals(count($contentInDB), count($content)); | ||
202 | $this->assertArrayHasKey('id', $content[0]); | 210 | $this->assertArrayHasKey('id', $content[0]); |
203 | $this->assertArrayHasKey('title', $content[0]); | 211 | $this->assertArrayHasKey('title', $content[0]); |
204 | $this->assertArrayHasKey('url', $content[0]); | 212 | $this->assertArrayHasKey('url', $content[0]); |
@@ -212,6 +220,17 @@ class ExportControllerTest extends WallabagCoreTestCase | |||
212 | $this->assertArrayHasKey('tags', $content[0]); | 220 | $this->assertArrayHasKey('tags', $content[0]); |
213 | $this->assertArrayHasKey('created_at', $content[0]); | 221 | $this->assertArrayHasKey('created_at', $content[0]); |
214 | $this->assertArrayHasKey('updated_at', $content[0]); | 222 | $this->assertArrayHasKey('updated_at', $content[0]); |
223 | |||
224 | $this->assertEquals($contentInDB->isArchived(), $content[0]['is_archived']); | ||
225 | $this->assertEquals($contentInDB->isStarred(), $content[0]['is_starred']); | ||
226 | $this->assertEquals($contentInDB->getTitle(), $content[0]['title']); | ||
227 | $this->assertEquals($contentInDB->getUrl(), $content[0]['url']); | ||
228 | $this->assertEquals([['text' => 'This is my annotation /o/', 'quote' => 'content']], $content[0]['annotations']); | ||
229 | $this->assertEquals($contentInDB->getMimetype(), $content[0]['mimetype']); | ||
230 | $this->assertEquals($contentInDB->getLanguage(), $content[0]['language']); | ||
231 | $this->assertEquals($contentInDB->getReadingtime(), $content[0]['reading_time']); | ||
232 | $this->assertEquals($contentInDB->getDomainname(), $content[0]['domain_name']); | ||
233 | $this->assertEquals(['foo', 'baz'], $content[0]['tags']); | ||
215 | } | 234 | } |
216 | 235 | ||
217 | public function testXmlExport() | 236 | public function testXmlExport() |
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php index 2c32393f..769ce66e 100644 --- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php | |||
@@ -3,6 +3,7 @@ | |||
3 | namespace Tests\Wallabag\CoreBundle\Controller; | 3 | namespace Tests\Wallabag\CoreBundle\Controller; |
4 | 4 | ||
5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | 5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; |
6 | use Wallabag\CoreBundle\Entity\Tag; | ||
6 | 7 | ||
7 | class TagControllerTest extends WallabagCoreTestCase | 8 | class TagControllerTest extends WallabagCoreTestCase |
8 | { | 9 | { |
@@ -26,7 +27,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
26 | $entry = $client->getContainer() | 27 | $entry = $client->getContainer() |
27 | ->get('doctrine.orm.entity_manager') | 28 | ->get('doctrine.orm.entity_manager') |
28 | ->getRepository('WallabagCoreBundle:Entry') | 29 | ->getRepository('WallabagCoreBundle:Entry') |
29 | ->findOneByUsernameAndNotArchived('admin'); | 30 | ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId()); |
30 | 31 | ||
31 | $crawler = $client->request('GET', '/view/'.$entry->getId()); | 32 | $crawler = $client->request('GET', '/view/'.$entry->getId()); |
32 | 33 | ||
@@ -43,9 +44,9 @@ class TagControllerTest extends WallabagCoreTestCase | |||
43 | $entry = $client->getContainer() | 44 | $entry = $client->getContainer() |
44 | ->get('doctrine.orm.entity_manager') | 45 | ->get('doctrine.orm.entity_manager') |
45 | ->getRepository('WallabagCoreBundle:Entry') | 46 | ->getRepository('WallabagCoreBundle:Entry') |
46 | ->findOneByUsernameAndNotArchived('admin'); | 47 | ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId()); |
47 | 48 | ||
48 | $this->assertEquals(1, count($entry->getTags())); | 49 | $this->assertEquals(3, count($entry->getTags())); |
49 | 50 | ||
50 | // tag already exists and already assigned | 51 | // tag already exists and already assigned |
51 | $client->submit($form, $data); | 52 | $client->submit($form, $data); |
@@ -56,7 +57,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
56 | ->getRepository('WallabagCoreBundle:Entry') | 57 | ->getRepository('WallabagCoreBundle:Entry') |
57 | ->find($entry->getId()); | 58 | ->find($entry->getId()); |
58 | 59 | ||
59 | $this->assertEquals(1, count($newEntry->getTags())); | 60 | $this->assertEquals(3, count($newEntry->getTags())); |
60 | 61 | ||
61 | // tag already exists but still not assigned to this entry | 62 | // tag already exists but still not assigned to this entry |
62 | $data = [ | 63 | $data = [ |
@@ -71,7 +72,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
71 | ->getRepository('WallabagCoreBundle:Entry') | 72 | ->getRepository('WallabagCoreBundle:Entry') |
72 | ->find($entry->getId()); | 73 | ->find($entry->getId()); |
73 | 74 | ||
74 | $this->assertEquals(2, count($newEntry->getTags())); | 75 | $this->assertEquals(3, count($newEntry->getTags())); |
75 | } | 76 | } |
76 | 77 | ||
77 | public function testAddMultipleTagToEntry() | 78 | public function testAddMultipleTagToEntry() |
@@ -82,7 +83,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
82 | $entry = $client->getContainer() | 83 | $entry = $client->getContainer() |
83 | ->get('doctrine.orm.entity_manager') | 84 | ->get('doctrine.orm.entity_manager') |
84 | ->getRepository('WallabagCoreBundle:Entry') | 85 | ->getRepository('WallabagCoreBundle:Entry') |
85 | ->findOneByUsernameAndNotArchived('admin'); | 86 | ->findByUrlAndUserId('http://0.0.0.0/entry2', $this->getLoggedInUserId()); |
86 | 87 | ||
87 | $crawler = $client->request('GET', '/view/'.$entry->getId()); | 88 | $crawler = $client->request('GET', '/view/'.$entry->getId()); |
88 | 89 | ||
@@ -101,9 +102,13 @@ class TagControllerTest extends WallabagCoreTestCase | |||
101 | ->find($entry->getId()); | 102 | ->find($entry->getId()); |
102 | 103 | ||
103 | $tags = $newEntry->getTags()->toArray(); | 104 | $tags = $newEntry->getTags()->toArray(); |
105 | foreach ($tags as $key => $tag) { | ||
106 | $tags[$key] = $tag->getLabel(); | ||
107 | } | ||
108 | |||
104 | $this->assertGreaterThanOrEqual(2, count($tags)); | 109 | $this->assertGreaterThanOrEqual(2, count($tags)); |
105 | $this->assertNotEquals(false, array_search('foo2', $tags), 'Tag foo2 is assigned to the entry'); | 110 | $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'); | 111 | $this->assertNotFalse(array_search('bar2', $tags), 'Tag bar2 is assigned to the entry'); |
107 | } | 112 | } |
108 | 113 | ||
109 | public function testRemoveTagFromEntry() | 114 | public function testRemoveTagFromEntry() |
@@ -114,7 +119,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
114 | $entry = $client->getContainer() | 119 | $entry = $client->getContainer() |
115 | ->get('doctrine.orm.entity_manager') | 120 | ->get('doctrine.orm.entity_manager') |
116 | ->getRepository('WallabagCoreBundle:Entry') | 121 | ->getRepository('WallabagCoreBundle:Entry') |
117 | ->findOneByUsernameAndNotArchived('admin'); | 122 | ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId()); |
118 | 123 | ||
119 | $tag = $client->getContainer() | 124 | $tag = $client->getContainer() |
120 | ->get('doctrine.orm.entity_manager') | 125 | ->get('doctrine.orm.entity_manager') |
@@ -130,36 +135,48 @@ class TagControllerTest extends WallabagCoreTestCase | |||
130 | $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId()); | 135 | $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId()); |
131 | 136 | ||
132 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); | 137 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); |
138 | |||
139 | $tag = $client->getContainer() | ||
140 | ->get('doctrine.orm.entity_manager') | ||
141 | ->getRepository('WallabagCoreBundle:Tag') | ||
142 | ->findOneByLabel($this->tagName); | ||
143 | |||
144 | $this->assertNull($tag, $this->tagName.' was removed because it begun an orphan tag'); | ||
133 | } | 145 | } |
134 | 146 | ||
135 | public function testShowEntriesForTagAction() | 147 | public function testShowEntriesForTagAction() |
136 | { | 148 | { |
137 | $this->logInAs('admin'); | 149 | $this->logInAs('admin'); |
138 | $client = $this->getClient(); | 150 | $client = $this->getClient(); |
151 | $em = $client->getContainer() | ||
152 | ->get('doctrine.orm.entity_manager'); | ||
153 | |||
154 | $tag = new Tag(); | ||
155 | $tag->setLabel($this->tagName); | ||
139 | 156 | ||
140 | $entry = $client->getContainer() | 157 | $entry = $client->getContainer() |
141 | ->get('doctrine.orm.entity_manager') | 158 | ->get('doctrine.orm.entity_manager') |
142 | ->getRepository('WallabagCoreBundle:Entry') | 159 | ->getRepository('WallabagCoreBundle:Entry') |
143 | ->findOneByUsernameAndNotArchived('admin'); | 160 | ->findByUrlAndUserId('http://0.0.0.0/entry4', $this->getLoggedInUserId()); |
144 | 161 | ||
145 | $tag = $client->getContainer() | 162 | $tag->addEntry($entry); |
146 | ->get('doctrine.orm.entity_manager') | ||
147 | ->getRepository('WallabagCoreBundle:Tag') | ||
148 | ->findOneByEntryAndTagLabel($entry, 'foo'); | ||
149 | 163 | ||
150 | $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug()); | 164 | $em->persist($entry); |
151 | 165 | $em->persist($tag); | |
152 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 166 | $em->flush(); |
153 | $this->assertCount(2, $crawler->filter('div[class=entry]')); | ||
154 | 167 | ||
155 | $tag = $client->getContainer() | 168 | $tag = $client->getContainer() |
156 | ->get('doctrine.orm.entity_manager') | 169 | ->get('doctrine.orm.entity_manager') |
157 | ->getRepository('WallabagCoreBundle:Tag') | 170 | ->getRepository('WallabagCoreBundle:Tag') |
158 | ->findOneByLabel('baz'); | 171 | ->findOneByEntryAndTagLabel($entry, $this->tagName); |
159 | 172 | ||
160 | $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug()); | 173 | $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug()); |
161 | 174 | ||
162 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 175 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
163 | $this->assertCount(0, $crawler->filter('div[class=entry]')); | 176 | $this->assertCount(1, $crawler->filter('[id*="entry-"]')); |
177 | |||
178 | $entry->removeTag($tag); | ||
179 | $em->remove($tag); | ||
180 | $em->flush(); | ||
164 | } | 181 | } |
165 | } | 182 | } |
diff --git a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php index 19b824b8..243a4459 100644 --- a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php +++ b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php | |||
@@ -23,7 +23,7 @@ class ManageControllerTest extends WallabagCoreTestCase | |||
23 | 23 | ||
24 | // Create a new user in the database | 24 | // Create a new user in the database |
25 | $crawler = $client->request('GET', '/users/'); | 25 | $crawler = $client->request('GET', '/users/'); |
26 | $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /users/"); | 26 | $this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Unexpected HTTP status code for GET /users/'); |
27 | $crawler = $client->click($crawler->selectLink('user.list.create_new_one')->link()); | 27 | $crawler = $client->click($crawler->selectLink('user.list.create_new_one')->link()); |
28 | 28 | ||
29 | // Fill in the form and submit it | 29 | // Fill in the form and submit it |
diff --git a/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php index 0cebd3e4..a78b77bc 100644 --- a/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php +++ b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php | |||
@@ -41,26 +41,6 @@ class CreateConfigListenerTest extends \PHPUnit_Framework_TestCase | |||
41 | $this->response = Response::create(); | 41 | $this->response = Response::create(); |
42 | } | 42 | } |
43 | 43 | ||
44 | public function testWithInvalidUser() | ||
45 | { | ||
46 | $user = new User(); | ||
47 | $user->setEnabled(false); | ||
48 | |||
49 | $event = new FilterUserResponseEvent( | ||
50 | $user, | ||
51 | $this->request, | ||
52 | $this->response | ||
53 | ); | ||
54 | |||
55 | $this->em->expects($this->never())->method('persist'); | ||
56 | $this->em->expects($this->never())->method('flush'); | ||
57 | |||
58 | $this->dispatcher->dispatch( | ||
59 | FOSUserEvents::REGISTRATION_COMPLETED, | ||
60 | $event | ||
61 | ); | ||
62 | } | ||
63 | |||
64 | public function testWithValidUser() | 44 | public function testWithValidUser() |
65 | { | 45 | { |
66 | $user = new User(); | 46 | $user = new User(); |