aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php52
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php14
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php6
3 files changed, 69 insertions, 3 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index 4aa60e90..067aed2c 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -128,6 +128,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
128 'perPage' => 2, 128 'perPage' => 2,
129 'tags' => 'foo', 129 'tags' => 'foo',
130 'since' => 1443274283, 130 'since' => 1443274283,
131 'public' => 0,
131 ]); 132 ]);
132 133
133 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 134 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@@ -154,6 +155,53 @@ class EntryRestControllerTest extends WallabagApiTestCase
154 $this->assertContains('order=asc', $content['_links'][$link]['href']); 155 $this->assertContains('order=asc', $content['_links'][$link]['href']);
155 $this->assertContains('tags=foo', $content['_links'][$link]['href']); 156 $this->assertContains('tags=foo', $content['_links'][$link]['href']);
156 $this->assertContains('since=1443274283', $content['_links'][$link]['href']); 157 $this->assertContains('since=1443274283', $content['_links'][$link]['href']);
158 $this->assertContains('public=0', $content['_links'][$link]['href']);
159 }
160
161 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
162 }
163
164 public function testGetEntriesPublicOnly()
165 {
166 $entry = $this->client->getContainer()
167 ->get('doctrine.orm.entity_manager')
168 ->getRepository('WallabagCoreBundle:Entry')
169 ->findOneByUser(1);
170
171 if (!$entry) {
172 $this->markTestSkipped('No content found in db.');
173 }
174
175 // generate at least one public entry
176 $entry->generateUid();
177
178 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
179 $em->persist($entry);
180 $em->flush();
181
182 $this->client->request('GET', '/api/entries', [
183 'public' => 1,
184 ]);
185
186 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
187
188 $content = json_decode($this->client->getResponse()->getContent(), true);
189
190 $this->assertGreaterThanOrEqual(1, count($content));
191 $this->assertArrayHasKey('items', $content['_embedded']);
192 $this->assertGreaterThanOrEqual(1, $content['total']);
193 $this->assertEquals(1, $content['page']);
194 $this->assertEquals(30, $content['limit']);
195 $this->assertGreaterThanOrEqual(1, $content['pages']);
196
197 $this->assertArrayHasKey('_links', $content);
198 $this->assertArrayHasKey('self', $content['_links']);
199 $this->assertArrayHasKey('first', $content['_links']);
200 $this->assertArrayHasKey('last', $content['_links']);
201
202 foreach (['self', 'first', 'last'] as $link) {
203 $this->assertArrayHasKey('href', $content['_links'][$link]);
204 $this->assertContains('public=1', $content['_links'][$link]['href']);
157 } 205 }
158 206
159 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 207 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
@@ -348,6 +396,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
348 'language' => 'de', 396 'language' => 'de',
349 'published_at' => '2016-09-08T11:55:58+0200', 397 'published_at' => '2016-09-08T11:55:58+0200',
350 'authors' => 'bob,helen', 398 'authors' => 'bob,helen',
399 'public' => 1,
351 ]); 400 ]);
352 401
353 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 402 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@@ -367,6 +416,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
367 $this->assertCount(2, $content['published_by']); 416 $this->assertCount(2, $content['published_by']);
368 $this->assertContains('bob', $content['published_by']); 417 $this->assertContains('bob', $content['published_by']);
369 $this->assertContains('helen', $content['published_by']); 418 $this->assertContains('helen', $content['published_by']);
419 $this->assertTrue($content['is_public'], 'A public link has been generated for that entry');
370 } 420 }
371 421
372 public function testPostSameEntry() 422 public function testPostSameEntry()
@@ -481,6 +531,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
481 'preview_picture' => 'http://preview.io/picture.jpg', 531 'preview_picture' => 'http://preview.io/picture.jpg',
482 'authors' => 'bob,sponge', 532 'authors' => 'bob,sponge',
483 'content' => 'awesome', 533 'content' => 'awesome',
534 'public' => 0,
484 ]); 535 ]);
485 536
486 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 537 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@@ -497,6 +548,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
497 $this->assertContains('sponge', $content['published_by']); 548 $this->assertContains('sponge', $content['published_by']);
498 $this->assertContains('bob', $content['published_by']); 549 $this->assertContains('bob', $content['published_by']);
499 $this->assertEquals('awesome', $content['content']); 550 $this->assertEquals('awesome', $content['content']);
551 $this->assertFalse($content['is_public'], 'Entry is no more shared');
500 } 552 }
501 553
502 public function testPatchEntryWithoutQuotes() 554 public function testPatchEntryWithoutQuotes()
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index f17dc97b..7cf28bfe 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -861,6 +861,20 @@ class EntryControllerTest extends WallabagCoreTestCase
861 $this->assertCount(1, $crawler->filter('div[class=entry]')); 861 $this->assertCount(1, $crawler->filter('div[class=entry]'));
862 } 862 }
863 863
864 public function testFilterOnIsPublic()
865 {
866 $this->logInAs('admin');
867 $this->useTheme('baggy');
868 $client = $this->getClient();
869
870 $crawler = $client->request('GET', '/unread/list');
871 $form = $crawler->filter('button[id=submit-filter]')->form();
872 $form['entry_filter[isPublic]']->tick();
873
874 $crawler = $client->submit($form);
875 $this->assertCount(0, $crawler->filter('div[class=entry]'));
876 }
877
864 public function testPreviewPictureFilter() 878 public function testPreviewPictureFilter()
865 { 879 {
866 $this->logInAs('admin'); 880 $this->logInAs('admin');
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index 95dd75ba..dbddbc5c 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -206,7 +206,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
206 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 206 $this->assertEquals('http://1.1.1.1', $entry->getUrl());
207 $this->assertEquals('this is my title', $entry->getTitle()); 207 $this->assertEquals('this is my title', $entry->getTitle());
208 $this->assertContains('this is my content', $entry->getContent()); 208 $this->assertContains('this is my content', $entry->getContent());
209 $this->assertEmpty($entry->getPreviewPicture()); 209 $this->assertNull($entry->getPreviewPicture());
210 $this->assertEquals('text/html', $entry->getMimetype()); 210 $this->assertEquals('text/html', $entry->getMimetype());
211 $this->assertEquals('fr', $entry->getLanguage()); 211 $this->assertEquals('fr', $entry->getLanguage());
212 $this->assertEquals('200', $entry->getHttpStatus()); 212 $this->assertEquals('200', $entry->getHttpStatus());
@@ -252,7 +252,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
252 $this->assertEquals('this is my title', $entry->getTitle()); 252 $this->assertEquals('this is my title', $entry->getTitle());
253 $this->assertContains('this is my content', $entry->getContent()); 253 $this->assertContains('this is my content', $entry->getContent());
254 $this->assertEquals('text/html', $entry->getMimetype()); 254 $this->assertEquals('text/html', $entry->getMimetype());
255 $this->assertEmpty($entry->getLanguage()); 255 $this->assertNull($entry->getLanguage());
256 $this->assertEquals('200', $entry->getHttpStatus()); 256 $this->assertEquals('200', $entry->getHttpStatus());
257 $this->assertEquals(4.0, $entry->getReadingTime()); 257 $this->assertEquals(4.0, $entry->getReadingTime());
258 $this->assertEquals('1.1.1.1', $entry->getDomainName()); 258 $this->assertEquals('1.1.1.1', $entry->getDomainName());
@@ -300,7 +300,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
300 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 300 $this->assertEquals('http://1.1.1.1', $entry->getUrl());
301 $this->assertEquals('this is my title', $entry->getTitle()); 301 $this->assertEquals('this is my title', $entry->getTitle());
302 $this->assertContains('this is my content', $entry->getContent()); 302 $this->assertContains('this is my content', $entry->getContent());
303 $this->assertEmpty($entry->getPreviewPicture()); 303 $this->assertNull($entry->getPreviewPicture());
304 $this->assertEquals('text/html', $entry->getMimetype()); 304 $this->assertEquals('text/html', $entry->getMimetype());
305 $this->assertEquals('fr', $entry->getLanguage()); 305 $this->assertEquals('fr', $entry->getLanguage());
306 $this->assertEquals('200', $entry->getHttpStatus()); 306 $this->assertEquals('200', $entry->getHttpStatus());