aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php60
1 files changed, 48 insertions, 12 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 7db4cf1f..19c8698e 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -135,9 +135,45 @@ class EntryControllerTest extends WallabagCoreTestCase
135 ->getRepository('WallabagCoreBundle:Entry') 135 ->getRepository('WallabagCoreBundle:Entry')
136 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); 136 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
137 137
138 $author = $content->getPublishedBy();
139
138 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); 140 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
139 $this->assertEquals($this->url, $content->getUrl()); 141 $this->assertEquals($this->url, $content->getUrl());
140 $this->assertContains('Google', $content->getTitle()); 142 $this->assertContains('Google', $content->getTitle());
143 $this->assertEquals('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s'));
144 $this->assertEquals('Morgane Tual', $author[0]);
145 $this->assertArrayHasKey('x-varnish1', $content->getHeaders());
146 }
147
148 public function testPostWithMultipleAuthors()
149 {
150 $url = 'http://www.liberation.fr/planete/2017/04/05/donald-trump-et-xi-jinping-tentative-de-flirt-en-floride_1560768';
151 $this->logInAs('admin');
152 $client = $this->getClient();
153
154 $crawler = $client->request('GET', '/new');
155
156 $this->assertEquals(200, $client->getResponse()->getStatusCode());
157
158 $form = $crawler->filter('form[name=entry]')->form();
159
160 $data = [
161 'entry[url]' => $url,
162 ];
163
164 $client->submit($form, $data);
165
166 $this->assertEquals(302, $client->getResponse()->getStatusCode());
167
168 $content = $client->getContainer()
169 ->get('doctrine.orm.entity_manager')
170 ->getRepository('WallabagCoreBundle:Entry')
171 ->findByUrlAndUserId($url, $this->getLoggedInUserId());
172
173 $authors = $content->getPublishedBy();
174 $this->assertEquals('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s'));
175 $this->assertEquals('Raphaël Balenieri, correspondant à Pékin', $authors[0]);
176 $this->assertEquals('Frédéric Autran, correspondant à New York', $authors[1]);
141 } 177 }
142 178
143 public function testPostNewOkUrlExist() 179 public function testPostNewOkUrlExist()
@@ -235,7 +271,7 @@ class EntryControllerTest extends WallabagCoreTestCase
235 ->findOneByUrl($url); 271 ->findOneByUrl($url);
236 $tags = $entry->getTags(); 272 $tags = $entry->getTags();
237 273
238 $this->assertCount(1, $tags); 274 $this->assertCount(2, $tags);
239 $this->assertEquals('wallabag', $tags[0]->getLabel()); 275 $this->assertEquals('wallabag', $tags[0]->getLabel());
240 276
241 $em->remove($entry); 277 $em->remove($entry);
@@ -264,8 +300,8 @@ class EntryControllerTest extends WallabagCoreTestCase
264 300
265 $tags = $entry->getTags(); 301 $tags = $entry->getTags();
266 302
267 $this->assertCount(1, $tags); 303 $this->assertCount(2, $tags);
268 $this->assertEquals('wallabag', $tags[0]->getLabel()); 304 $this->assertEquals('wallabag', $tags[1]->getLabel());
269 305
270 $em->remove($entry); 306 $em->remove($entry);
271 $em->flush(); 307 $em->flush();
@@ -626,7 +662,7 @@ class EntryControllerTest extends WallabagCoreTestCase
626 662
627 $crawler = $client->submit($form, $data); 663 $crawler = $client->submit($form, $data);
628 664
629 $this->assertCount(2, $crawler->filter('div[class=entry]')); 665 $this->assertCount(3, $crawler->filter('div[class=entry]'));
630 } 666 }
631 667
632 public function testFilterOnReadingTimeOnlyLower() 668 public function testFilterOnReadingTimeOnlyLower()
@@ -662,7 +698,7 @@ class EntryControllerTest extends WallabagCoreTestCase
662 698
663 $crawler = $client->submit($form, $data); 699 $crawler = $client->submit($form, $data);
664 700
665 $this->assertCount(4, $crawler->filter('div[class=entry]')); 701 $this->assertCount(5, $crawler->filter('div[class=entry]'));
666 } 702 }
667 703
668 public function testFilterOnCreationDate() 704 public function testFilterOnCreationDate()
@@ -681,7 +717,7 @@ class EntryControllerTest extends WallabagCoreTestCase
681 717
682 $crawler = $client->submit($form, $data); 718 $crawler = $client->submit($form, $data);
683 719
684 $this->assertCount(5, $crawler->filter('div[class=entry]')); 720 $this->assertCount(6, $crawler->filter('div[class=entry]'));
685 721
686 $data = [ 722 $data = [
687 'entry_filter[createdAt][left_date]' => date('d/m/Y'), 723 'entry_filter[createdAt][left_date]' => date('d/m/Y'),
@@ -690,7 +726,7 @@ class EntryControllerTest extends WallabagCoreTestCase
690 726
691 $crawler = $client->submit($form, $data); 727 $crawler = $client->submit($form, $data);
692 728
693 $this->assertCount(5, $crawler->filter('div[class=entry]')); 729 $this->assertCount(6, $crawler->filter('div[class=entry]'));
694 730
695 $data = [ 731 $data = [
696 'entry_filter[createdAt][left_date]' => '01/01/1970', 732 'entry_filter[createdAt][left_date]' => '01/01/1970',
@@ -794,7 +830,7 @@ class EntryControllerTest extends WallabagCoreTestCase
794 $form['entry_filter[previewPicture]']->tick(); 830 $form['entry_filter[previewPicture]']->tick();
795 831
796 $crawler = $client->submit($form); 832 $crawler = $client->submit($form);
797 $this->assertCount(1, $crawler->filter('div[class=entry]')); 833 $this->assertCount(2, $crawler->filter('div[class=entry]'));
798 } 834 }
799 835
800 public function testFilterOnLanguage() 836 public function testFilterOnLanguage()
@@ -809,7 +845,7 @@ class EntryControllerTest extends WallabagCoreTestCase
809 ]; 845 ];
810 846
811 $crawler = $client->submit($form, $data); 847 $crawler = $client->submit($form, $data);
812 $this->assertCount(2, $crawler->filter('div[class=entry]')); 848 $this->assertCount(3, $crawler->filter('div[class=entry]'));
813 849
814 $form = $crawler->filter('button[id=submit-filter]')->form(); 850 $form = $crawler->filter('button[id=submit-filter]')->form();
815 $data = [ 851 $data = [
@@ -899,7 +935,7 @@ class EntryControllerTest extends WallabagCoreTestCase
899 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry); 935 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry);
900 $this->assertEquals($url, $entry->getUrl()); 936 $this->assertEquals($url, $entry->getUrl());
901 $this->assertContains('Perpignan', $entry->getTitle()); 937 $this->assertContains('Perpignan', $entry->getTitle());
902 $this->assertContains('/d9bc0fcd.jpeg', $entry->getContent()); 938 $this->assertContains('/c4789a7f.jpeg', $entry->getContent());
903 939
904 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0); 940 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
905 } 941 }
@@ -1034,7 +1070,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1034 1070
1035 $crawler = $client->submit($form, $data); 1071 $crawler = $client->submit($form, $data);
1036 1072
1037 $this->assertCount(1, $crawler->filter('div[class=entry]')); 1073 $this->assertCount(2, $crawler->filter('div[class=entry]'));
1038 1074
1039 $crawler = $client->request('GET', '/all/list'); 1075 $crawler = $client->request('GET', '/all/list');
1040 $form = $crawler->filter('button[id=submit-filter]')->form(); 1076 $form = $crawler->filter('button[id=submit-filter]')->form();
@@ -1045,7 +1081,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1045 1081
1046 $crawler = $client->submit($form, $data); 1082 $crawler = $client->submit($form, $data);
1047 1083
1048 $this->assertCount(7, $crawler->filter('div[class=entry]')); 1084 $this->assertCount(8, $crawler->filter('div[class=entry]'));
1049 } 1085 }
1050 1086
1051 public function testSearch() 1087 public function testSearch()