aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/DeveloperControllerTest.php9
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php53
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php6
-rw-r--r--tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php15
-rw-r--r--tests/Wallabag/CoreBundle/Controller/TagControllerTest.php31
5 files changed, 112 insertions, 2 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/DeveloperControllerTest.php b/tests/Wallabag/CoreBundle/Controller/DeveloperControllerTest.php
index 79452ace..97ed0d58 100644
--- a/tests/Wallabag/CoreBundle/Controller/DeveloperControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/DeveloperControllerTest.php
@@ -18,12 +18,19 @@ class DeveloperControllerTest extends WallabagCoreTestCase
18 18
19 $form = $crawler->filter('button[type=submit]')->form(); 19 $form = $crawler->filter('button[type=submit]')->form();
20 20
21 $client->submit($form); 21 $data = [
22 'client[name]' => 'My app',
23 ];
24
25 $crawler = $client->submit($form, $data);
22 26
23 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 27 $this->assertEquals(200, $client->getResponse()->getStatusCode());
24 28
25 $newNbClients = $em->getRepository('WallabagApiBundle:Client')->findAll(); 29 $newNbClients = $em->getRepository('WallabagApiBundle:Client')->findAll();
26 $this->assertGreaterThan(count($nbClients), count($newNbClients)); 30 $this->assertGreaterThan(count($nbClients), count($newNbClients));
31
32 $this->assertGreaterThan(1, $alert = $crawler->filter('.settings ul li strong')->extract(['_text']));
33 $this->assertContains('My app', $alert[0]);
27 } 34 }
28 35
29 public function testListingClient() 36 public function testListingClient()
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 5c739c78..a74c17d9 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -236,6 +236,16 @@ class EntryControllerTest extends WallabagCoreTestCase
236 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 236 $this->assertEquals(200, $client->getResponse()->getStatusCode());
237 } 237 }
238 238
239 public function testUntagged()
240 {
241 $this->logInAs('admin');
242 $client = $this->getClient();
243
244 $client->request('GET', '/untagged/list');
245
246 $this->assertEquals(200, $client->getResponse()->getStatusCode());
247 }
248
239 public function testStarred() 249 public function testStarred()
240 { 250 {
241 $this->logInAs('admin'); 251 $this->logInAs('admin');
@@ -698,4 +708,47 @@ class EntryControllerTest extends WallabagCoreTestCase
698 $crawler = $client->submit($form, $data); 708 $crawler = $client->submit($form, $data);
699 $this->assertCount(2, $crawler->filter('div[class=entry]')); 709 $this->assertCount(2, $crawler->filter('div[class=entry]'));
700 } 710 }
711
712 public function testCache()
713 {
714 $this->logInAs('admin');
715 $client = $this->getClient();
716
717 $content = $client->getContainer()
718 ->get('doctrine.orm.entity_manager')
719 ->getRepository('WallabagCoreBundle:Entry')
720 ->findOneByUser($this->getLoggedInUserId());
721
722 // no uuid
723 $client->request('GET', '/share/'.$content->getUuid());
724 $this->assertEquals(404, $client->getResponse()->getStatusCode());
725
726 // generating the uuid
727 $client->request('GET', '/share/'.$content->getId());
728 $this->assertEquals(302, $client->getResponse()->getStatusCode());
729
730 // follow link with uuid
731 $crawler = $client->followRedirect();
732 $this->assertEquals(200, $client->getResponse()->getStatusCode());
733 $this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control'));
734 $this->assertContains('public', $client->getResponse()->headers->get('cache-control'));
735 $this->assertContains('s-maxage=25200', $client->getResponse()->headers->get('cache-control'));
736 $this->assertNotContains('no-cache', $client->getResponse()->headers->get('cache-control'));
737
738 // sharing is now disabled
739 $client->getContainer()->get('craue_config')->set('share_public', 0);
740 $client->request('GET', '/share/'.$content->getUuid());
741 $this->assertEquals(404, $client->getResponse()->getStatusCode());
742
743 $client->request('GET', '/view/'.$content->getId());
744 $this->assertContains('no-cache', $client->getResponse()->headers->get('cache-control'));
745
746 // removing the share
747 $client->request('GET', '/share/delete/'.$content->getId());
748 $this->assertEquals(302, $client->getResponse()->getStatusCode());
749
750 // share is now disable
751 $client->request('GET', '/share/'.$content->getUuid());
752 $this->assertEquals(404, $client->getResponse()->getStatusCode());
753 }
701} 754}
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
index b22156c3..47b86117 100644
--- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
@@ -168,7 +168,7 @@ class ExportControllerTest extends WallabagCoreTestCase
168 $this->assertGreaterThan(1, $csv); 168 $this->assertGreaterThan(1, $csv);
169 // +1 for title line 169 // +1 for title line
170 $this->assertEquals(count($contentInDB) + 1, count($csv)); 170 $this->assertEquals(count($contentInDB) + 1, count($csv));
171 $this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language', $csv[0]); 171 $this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]);
172 } 172 }
173 173
174 public function testJsonExport() 174 public function testJsonExport()
@@ -210,6 +210,8 @@ class ExportControllerTest extends WallabagCoreTestCase
210 $this->assertArrayHasKey('reading_time', $content[0]); 210 $this->assertArrayHasKey('reading_time', $content[0]);
211 $this->assertArrayHasKey('domain_name', $content[0]); 211 $this->assertArrayHasKey('domain_name', $content[0]);
212 $this->assertArrayHasKey('tags', $content[0]); 212 $this->assertArrayHasKey('tags', $content[0]);
213 $this->assertArrayHasKey('created_at', $content[0]);
214 $this->assertArrayHasKey('updated_at', $content[0]);
213 } 215 }
214 216
215 public function testXmlExport() 217 public function testXmlExport()
@@ -247,5 +249,7 @@ class ExportControllerTest extends WallabagCoreTestCase
247 $this->assertNotEmpty('url', (string) $content->entry[0]->url); 249 $this->assertNotEmpty('url', (string) $content->entry[0]->url);
248 $this->assertNotEmpty('content', (string) $content->entry[0]->content); 250 $this->assertNotEmpty('content', (string) $content->entry[0]->content);
249 $this->assertNotEmpty('domain_name', (string) $content->entry[0]->domain_name); 251 $this->assertNotEmpty('domain_name', (string) $content->entry[0]->domain_name);
252 $this->assertNotEmpty('created_at', (string) $content->entry[0]->created_at);
253 $this->assertNotEmpty('updated_at', (string) $content->entry[0]->updated_at);
250 } 254 }
251} 255}
diff --git a/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php b/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
index 03355f5a..08f4676e 100644
--- a/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
@@ -69,4 +69,19 @@ class SecurityControllerTest extends WallabagCoreTestCase
69 $this->assertTrue($user->isTrustedComputer('ABCDEF')); 69 $this->assertTrue($user->isTrustedComputer('ABCDEF'));
70 $this->assertFalse($user->isTrustedComputer('FEDCBA')); 70 $this->assertFalse($user->isTrustedComputer('FEDCBA'));
71 } 71 }
72
73 public function testEnabledRegistration()
74 {
75 $client = $this->getClient();
76
77 if (!$client->getContainer()->getParameter('fosuser_registration')) {
78 $this->markTestSkipped('fosuser_registration is not enabled.');
79
80 return;
81 }
82
83 $client->followRedirects();
84 $crawler = $client->request('GET', '/register');
85 $this->assertContains('registration.submit', $crawler->filter('body')->extract(['_text'])[0]);
86 }
72} 87}
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
index 58450e5f..71652760 100644
--- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
@@ -131,4 +131,35 @@ class TagControllerTest extends WallabagCoreTestCase
131 131
132 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 132 $this->assertEquals(404, $client->getResponse()->getStatusCode());
133 } 133 }
134
135 public function testShowEntriesForTagAction()
136 {
137 $this->logInAs('admin');
138 $client = $this->getClient();
139
140 $entry = $client->getContainer()
141 ->get('doctrine.orm.entity_manager')
142 ->getRepository('WallabagCoreBundle:Entry')
143 ->findOneByUsernameAndNotArchived('admin');
144
145 $tag = $client->getContainer()
146 ->get('doctrine.orm.entity_manager')
147 ->getRepository('WallabagCoreBundle:Tag')
148 ->findOneByEntryAndTagLabel($entry, 'foo');
149
150 $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug());
151
152 $this->assertEquals(200, $client->getResponse()->getStatusCode());
153 $this->assertCount(2, $crawler->filter('div[class=entry]'));
154
155 $tag = $client->getContainer()
156 ->get('doctrine.orm.entity_manager')
157 ->getRepository('WallabagCoreBundle:Tag')
158 ->findOneByLabel('baz');
159
160 $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug());
161
162 $this->assertEquals(200, $client->getResponse()->getStatusCode());
163 $this->assertCount(0, $crawler->filter('div[class=entry]'));
164 }
134} 165}