aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php67
-rw-r--r--tests/Wallabag/CoreBundle/Command/InstallCommandTest.php6
-rw-r--r--tests/Wallabag/CoreBundle/Controller/DeveloperControllerTest.php9
-rw-r--r--tests/Wallabag/CoreBundle/EventListener/LocaleListenerTest.php6
4 files changed, 80 insertions, 8 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php
index c39cc357..528366af 100644
--- a/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php
@@ -121,6 +121,73 @@ class WallabagRestControllerTest extends WallabagApiTestCase
121 ); 121 );
122 } 122 }
123 123
124 public function testGetTaggedEntries()
125 {
126 $this->client->request('GET', '/api/entries', ['tags' => 'foo,bar']);
127
128 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
129
130 $content = json_decode($this->client->getResponse()->getContent(), true);
131
132 $this->assertGreaterThanOrEqual(1, count($content));
133 $this->assertNotEmpty($content['_embedded']['items']);
134 $this->assertGreaterThanOrEqual(1, $content['total']);
135 $this->assertEquals(1, $content['page']);
136 $this->assertGreaterThanOrEqual(1, $content['pages']);
137
138 $this->assertTrue(
139 $this->client->getResponse()->headers->contains(
140 'Content-Type',
141 'application/json'
142 )
143 );
144 }
145
146 public function testGetDatedEntries()
147 {
148 $this->client->request('GET', '/api/entries', ['since' => 1]);
149
150 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
151
152 $content = json_decode($this->client->getResponse()->getContent(), true);
153
154 $this->assertGreaterThanOrEqual(1, count($content));
155 $this->assertNotEmpty($content['_embedded']['items']);
156 $this->assertGreaterThanOrEqual(1, $content['total']);
157 $this->assertEquals(1, $content['page']);
158 $this->assertGreaterThanOrEqual(1, $content['pages']);
159
160 $this->assertTrue(
161 $this->client->getResponse()->headers->contains(
162 'Content-Type',
163 'application/json'
164 )
165 );
166 }
167
168 public function testGetDatedSupEntries()
169 {
170 $future = new \DateTime(date('Y-m-d H:i:s'));
171 $this->client->request('GET', '/api/entries', ['since' => $future->getTimestamp() + 1000]);
172
173 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
174
175 $content = json_decode($this->client->getResponse()->getContent(), true);
176
177 $this->assertGreaterThanOrEqual(1, count($content));
178 $this->assertEmpty($content['_embedded']['items']);
179 $this->assertEquals(0, $content['total']);
180 $this->assertEquals(1, $content['page']);
181 $this->assertEquals(1, $content['pages']);
182
183 $this->assertTrue(
184 $this->client->getResponse()->headers->contains(
185 'Content-Type',
186 'application/json'
187 )
188 );
189 }
190
124 public function testDeleteEntry() 191 public function testDeleteEntry()
125 { 192 {
126 $entry = $this->client->getContainer() 193 $entry = $this->client->getContainer()
diff --git a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php
index 089a1c5f..c0133af4 100644
--- a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php
+++ b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php
@@ -87,7 +87,6 @@ class InstallCommandTest extends WallabagCoreTestCase
87 $this->assertContains('Setting up database.', $tester->getDisplay()); 87 $this->assertContains('Setting up database.', $tester->getDisplay());
88 $this->assertContains('Administration setup.', $tester->getDisplay()); 88 $this->assertContains('Administration setup.', $tester->getDisplay());
89 $this->assertContains('Config setup.', $tester->getDisplay()); 89 $this->assertContains('Config setup.', $tester->getDisplay());
90 $this->assertContains('Installing assets.', $tester->getDisplay());
91 } 90 }
92 91
93 public function testRunInstallCommandWithReset() 92 public function testRunInstallCommandWithReset()
@@ -119,7 +118,6 @@ class InstallCommandTest extends WallabagCoreTestCase
119 $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay()); 118 $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay());
120 $this->assertContains('Administration setup.', $tester->getDisplay()); 119 $this->assertContains('Administration setup.', $tester->getDisplay());
121 $this->assertContains('Config setup.', $tester->getDisplay()); 120 $this->assertContains('Config setup.', $tester->getDisplay());
122 $this->assertContains('Installing assets.', $tester->getDisplay());
123 121
124 // we force to reset everything 122 // we force to reset everything
125 $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay()); 123 $this->assertContains('Droping database, creating database and schema, clearing the cache', $tester->getDisplay());
@@ -164,7 +162,6 @@ class InstallCommandTest extends WallabagCoreTestCase
164 $this->assertContains('Setting up database.', $tester->getDisplay()); 162 $this->assertContains('Setting up database.', $tester->getDisplay());
165 $this->assertContains('Administration setup.', $tester->getDisplay()); 163 $this->assertContains('Administration setup.', $tester->getDisplay());
166 $this->assertContains('Config setup.', $tester->getDisplay()); 164 $this->assertContains('Config setup.', $tester->getDisplay());
167 $this->assertContains('Installing assets.', $tester->getDisplay());
168 165
169 // the current database doesn't already exist 166 // the current database doesn't already exist
170 $this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay()); 167 $this->assertContains('Creating database and schema, clearing the cache', $tester->getDisplay());
@@ -202,7 +199,6 @@ class InstallCommandTest extends WallabagCoreTestCase
202 $this->assertContains('Setting up database.', $tester->getDisplay()); 199 $this->assertContains('Setting up database.', $tester->getDisplay());
203 $this->assertContains('Administration setup.', $tester->getDisplay()); 200 $this->assertContains('Administration setup.', $tester->getDisplay());
204 $this->assertContains('Config setup.', $tester->getDisplay()); 201 $this->assertContains('Config setup.', $tester->getDisplay());
205 $this->assertContains('Installing assets.', $tester->getDisplay());
206 202
207 $this->assertContains('Droping schema and creating schema', $tester->getDisplay()); 203 $this->assertContains('Droping schema and creating schema', $tester->getDisplay());
208 } 204 }
@@ -257,7 +253,6 @@ class InstallCommandTest extends WallabagCoreTestCase
257 $this->assertContains('Setting up database.', $tester->getDisplay()); 253 $this->assertContains('Setting up database.', $tester->getDisplay());
258 $this->assertContains('Administration setup.', $tester->getDisplay()); 254 $this->assertContains('Administration setup.', $tester->getDisplay());
259 $this->assertContains('Config setup.', $tester->getDisplay()); 255 $this->assertContains('Config setup.', $tester->getDisplay());
260 $this->assertContains('Installing assets.', $tester->getDisplay());
261 256
262 $this->assertContains('Creating schema', $tester->getDisplay()); 257 $this->assertContains('Creating schema', $tester->getDisplay());
263 } 258 }
@@ -290,6 +285,5 @@ class InstallCommandTest extends WallabagCoreTestCase
290 $this->assertContains('Setting up database.', $tester->getDisplay()); 285 $this->assertContains('Setting up database.', $tester->getDisplay());
291 $this->assertContains('Administration setup.', $tester->getDisplay()); 286 $this->assertContains('Administration setup.', $tester->getDisplay());
292 $this->assertContains('Config setup.', $tester->getDisplay()); 287 $this->assertContains('Config setup.', $tester->getDisplay());
293 $this->assertContains('Installing assets.', $tester->getDisplay());
294 } 288 }
295} 289}
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/EventListener/LocaleListenerTest.php b/tests/Wallabag/CoreBundle/EventListener/LocaleListenerTest.php
index 2a7f9390..078bb69a 100644
--- a/tests/Wallabag/CoreBundle/EventListener/LocaleListenerTest.php
+++ b/tests/Wallabag/CoreBundle/EventListener/LocaleListenerTest.php
@@ -15,7 +15,11 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
15{ 15{
16 private function getEvent(Request $request) 16 private function getEvent(Request $request)
17 { 17 {
18 return new GetResponseEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, HttpKernelInterface::MASTER_REQUEST); 18 $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')
19 ->disableOriginalConstructor()
20 ->getMock();
21
22 return new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
19 } 23 }
20 24
21 public function testWithoutSession() 25 public function testWithoutSession()