aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2020-03-28 16:38:12 +0100
committerGitHub <noreply@github.com>2020-03-28 16:38:12 +0100
commit26467fa6b48d5ac2ea5fdab0e17eb1e585aee330 (patch)
treecdd84e67cc10eb3ea4e57bbb4efee52a1cafc00c /tests
parentdcfce5468186fb18f6a23af46fcdc2513adf1cc0 (diff)
parent8ee7b1603d23297a6c183105f79b1290ce9828bf (diff)
downloadwallabag-26467fa6b48d5ac2ea5fdab0e17eb1e585aee330.tar.gz
wallabag-26467fa6b48d5ac2ea5fdab0e17eb1e585aee330.tar.zst
wallabag-26467fa6b48d5ac2ea5fdab0e17eb1e585aee330.zip
Merge pull request #4299 from wallabag/fix/4133
Fix createdAt filter on material
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php101
1 files changed, 50 insertions, 51 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 3a8f92e7..3dcc1cd0 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -90,19 +90,18 @@ class EntryControllerTest extends WallabagCoreTestCase
90 public function testPostNewViaBookmarklet() 90 public function testPostNewViaBookmarklet()
91 { 91 {
92 $this->logInAs('admin'); 92 $this->logInAs('admin');
93 $this->useTheme('baggy');
94 $client = $this->getClient(); 93 $client = $this->getClient();
95 94
96 $crawler = $client->request('GET', '/'); 95 $crawler = $client->request('GET', '/');
97 96
98 $this->assertCount(4, $crawler->filter('div[class=entry]')); 97 $this->assertCount(4, $crawler->filter('li.entry'));
99 98
100 // Good URL 99 // Good URL
101 $client->request('GET', '/bookmarklet', ['url' => $this->url]); 100 $client->request('GET', '/bookmarklet', ['url' => $this->url]);
102 $this->assertSame(302, $client->getResponse()->getStatusCode()); 101 $this->assertSame(302, $client->getResponse()->getStatusCode());
103 $client->followRedirect(); 102 $client->followRedirect();
104 $crawler = $client->request('GET', '/'); 103 $crawler = $client->request('GET', '/');
105 $this->assertCount(5, $crawler->filter('div[class=entry]')); 104 $this->assertCount(5, $crawler->filter('li.entry'));
106 105
107 $em = $client->getContainer() 106 $em = $client->getContainer()
108 ->get('doctrine.orm.entity_manager'); 107 ->get('doctrine.orm.entity_manager');
@@ -694,7 +693,6 @@ class EntryControllerTest extends WallabagCoreTestCase
694 public function testFilterOnReadingTime() 693 public function testFilterOnReadingTime()
695 { 694 {
696 $this->logInAs('admin'); 695 $this->logInAs('admin');
697 $this->useTheme('baggy');
698 $client = $this->getClient(); 696 $client = $this->getClient();
699 $entry = new Entry($this->getLoggedInUser()); 697 $entry = new Entry($this->getLoggedInUser());
700 $entry->setUrl($this->url); 698 $entry->setUrl($this->url);
@@ -713,7 +711,7 @@ class EntryControllerTest extends WallabagCoreTestCase
713 711
714 $crawler = $client->submit($form, $data); 712 $crawler = $client->submit($form, $data);
715 713
716 $this->assertCount(1, $crawler->filter('div[class=entry]')); 714 $this->assertCount(1, $crawler->filter('li.entry'));
717 } 715 }
718 716
719 public function testFilterOnReadingTimeWithNegativeValue() 717 public function testFilterOnReadingTimeWithNegativeValue()
@@ -733,17 +731,16 @@ class EntryControllerTest extends WallabagCoreTestCase
733 $crawler = $client->submit($form, $data); 731 $crawler = $client->submit($form, $data);
734 732
735 // forcing negative value results in no entry displayed 733 // forcing negative value results in no entry displayed
736 $this->assertCount(0, $crawler->filter('div[class=entry]')); 734 $this->assertCount(0, $crawler->filter('li.entry'));
737 } 735 }
738 736
739 public function testFilterOnReadingTimeOnlyUpper() 737 public function testFilterOnReadingTimeOnlyUpper()
740 { 738 {
741 $this->logInAs('admin'); 739 $this->logInAs('admin');
742 $this->useTheme('baggy');
743 $client = $this->getClient(); 740 $client = $this->getClient();
744 741
745 $crawler = $client->request('GET', '/all/list'); 742 $crawler = $client->request('GET', '/all/list');
746 $this->assertCount(5, $crawler->filter('div[class=entry]')); 743 $this->assertCount(5, $crawler->filter('li.entry'));
747 744
748 $entry = new Entry($this->getLoggedInUser()); 745 $entry = new Entry($this->getLoggedInUser());
749 $entry->setUrl($this->url); 746 $entry->setUrl($this->url);
@@ -752,7 +749,7 @@ class EntryControllerTest extends WallabagCoreTestCase
752 $this->getEntityManager()->flush(); 749 $this->getEntityManager()->flush();
753 750
754 $crawler = $client->request('GET', '/all/list'); 751 $crawler = $client->request('GET', '/all/list');
755 $this->assertCount(6, $crawler->filter('div[class=entry]')); 752 $this->assertCount(6, $crawler->filter('li.entry'));
756 753
757 $form = $crawler->filter('button[id=submit-filter]')->form(); 754 $form = $crawler->filter('button[id=submit-filter]')->form();
758 755
@@ -762,13 +759,12 @@ class EntryControllerTest extends WallabagCoreTestCase
762 759
763 $crawler = $client->submit($form, $data); 760 $crawler = $client->submit($form, $data);
764 761
765 $this->assertCount(5, $crawler->filter('div[class=entry]')); 762 $this->assertCount(5, $crawler->filter('li.entry'));
766 } 763 }
767 764
768 public function testFilterOnReadingTimeOnlyLower() 765 public function testFilterOnReadingTimeOnlyLower()
769 { 766 {
770 $this->logInAs('admin'); 767 $this->logInAs('admin');
771 $this->useTheme('baggy');
772 $client = $this->getClient(); 768 $client = $this->getClient();
773 769
774 $crawler = $client->request('GET', '/unread/list'); 770 $crawler = $client->request('GET', '/unread/list');
@@ -781,7 +777,7 @@ class EntryControllerTest extends WallabagCoreTestCase
781 777
782 $crawler = $client->submit($form, $data); 778 $crawler = $client->submit($form, $data);
783 779
784 $this->assertCount(0, $crawler->filter('div[class=entry]')); 780 $this->assertCount(0, $crawler->filter('li.entry'));
785 781
786 $entry = new Entry($this->getLoggedInUser()); 782 $entry = new Entry($this->getLoggedInUser());
787 $entry->setUrl($this->url); 783 $entry->setUrl($this->url);
@@ -790,13 +786,12 @@ class EntryControllerTest extends WallabagCoreTestCase
790 $this->getEntityManager()->flush(); 786 $this->getEntityManager()->flush();
791 787
792 $crawler = $client->submit($form, $data); 788 $crawler = $client->submit($form, $data);
793 $this->assertCount(1, $crawler->filter('div[class=entry]')); 789 $this->assertCount(1, $crawler->filter('li.entry'));
794 } 790 }
795 791
796 public function testFilterOnUnreadStatus() 792 public function testFilterOnUnreadStatus()
797 { 793 {
798 $this->logInAs('admin'); 794 $this->logInAs('admin');
799 $this->useTheme('baggy');
800 $client = $this->getClient(); 795 $client = $this->getClient();
801 796
802 $crawler = $client->request('GET', '/all/list'); 797 $crawler = $client->request('GET', '/all/list');
@@ -809,7 +804,7 @@ class EntryControllerTest extends WallabagCoreTestCase
809 804
810 $crawler = $client->submit($form, $data); 805 $crawler = $client->submit($form, $data);
811 806
812 $this->assertCount(4, $crawler->filter('div[class=entry]')); 807 $this->assertCount(4, $crawler->filter('li.entry'));
813 808
814 $entry = new Entry($this->getLoggedInUser()); 809 $entry = new Entry($this->getLoggedInUser());
815 $entry->setUrl($this->url); 810 $entry->setUrl($this->url);
@@ -819,45 +814,56 @@ class EntryControllerTest extends WallabagCoreTestCase
819 814
820 $crawler = $client->submit($form, $data); 815 $crawler = $client->submit($form, $data);
821 816
822 $this->assertCount(5, $crawler->filter('div[class=entry]')); 817 $this->assertCount(5, $crawler->filter('li.entry'));
823 } 818 }
824 819
825 public function testFilterOnCreationDate() 820 public function testFilterOnCreationDate()
826 { 821 {
827 $this->logInAs('admin'); 822 $this->logInAs('admin');
828 $this->useTheme('baggy');
829 $client = $this->getClient(); 823 $client = $this->getClient();
830 824
825 $em = $this->getEntityManager();
826
827 $today = new \DateTimeImmutable();
828 $tomorrow = $today->add(new \DateInterval('P1D'));
829 $yesterday = $today->sub(new \DateInterval('P1D'));
830
831 $entry = new Entry($this->getLoggedInUser());
832 $entry->setUrl('http://0.0.0.0/testFilterOnCreationDate');
833 $entry->setCreatedAt($yesterday);
834 $em->persist($entry);
835 $em->flush();
836
831 $crawler = $client->request('GET', '/unread/list'); 837 $crawler = $client->request('GET', '/unread/list');
832 838
833 $form = $crawler->filter('button[id=submit-filter]')->form(); 839 $form = $crawler->filter('button[id=submit-filter]')->form();
834 840
835 $data = [ 841 $data = [
836 'entry_filter[createdAt][left_date]' => date('d/m/Y'), 842 'entry_filter[createdAt][left_date]' => $today->format('Y-m-d'),
837 'entry_filter[createdAt][right_date]' => date('d/m/Y', strtotime('+1 day')), 843 'entry_filter[createdAt][right_date]' => $tomorrow->format('Y-m-d'),
838 ]; 844 ];
839 845
840 $crawler = $client->submit($form, $data); 846 $crawler = $client->submit($form, $data);
841 847
842 $this->assertCount(5, $crawler->filter('div[class=entry]')); 848 $this->assertCount(5, $crawler->filter('li.entry'));
843 849
844 $data = [ 850 $data = [
845 'entry_filter[createdAt][left_date]' => date('d/m/Y'), 851 'entry_filter[createdAt][left_date]' => $today->format('Y-m-d'),
846 'entry_filter[createdAt][right_date]' => date('d/m/Y'), 852 'entry_filter[createdAt][right_date]' => $today->format('Y-m-d'),
847 ]; 853 ];
848 854
849 $crawler = $client->submit($form, $data); 855 $crawler = $client->submit($form, $data);
850 856
851 $this->assertCount(5, $crawler->filter('div[class=entry]')); 857 $this->assertCount(5, $crawler->filter('li.entry'));
852 858
853 $data = [ 859 $data = [
854 'entry_filter[createdAt][left_date]' => '01/01/1970', 860 'entry_filter[createdAt][left_date]' => '1970-01-01',
855 'entry_filter[createdAt][right_date]' => '01/01/1970', 861 'entry_filter[createdAt][right_date]' => '1970-01-01',
856 ]; 862 ];
857 863
858 $crawler = $client->submit($form, $data); 864 $crawler = $client->submit($form, $data);
859 865
860 $this->assertCount(0, $crawler->filter('div[class=entry]')); 866 $this->assertCount(0, $crawler->filter('li.entry'));
861 } 867 }
862 868
863 public function testPaginationWithFilter() 869 public function testPaginationWithFilter()
@@ -892,7 +898,6 @@ class EntryControllerTest extends WallabagCoreTestCase
892 public function testFilterOnDomainName() 898 public function testFilterOnDomainName()
893 { 899 {
894 $this->logInAs('admin'); 900 $this->logInAs('admin');
895 $this->useTheme('baggy');
896 $client = $this->getClient(); 901 $client = $this->getClient();
897 902
898 $crawler = $client->request('GET', '/unread/list'); 903 $crawler = $client->request('GET', '/unread/list');
@@ -902,7 +907,7 @@ class EntryControllerTest extends WallabagCoreTestCase
902 ]; 907 ];
903 908
904 $crawler = $client->submit($form, $data); 909 $crawler = $client->submit($form, $data);
905 $this->assertCount(5, $crawler->filter('div[class=entry]')); 910 $this->assertCount(5, $crawler->filter('li.entry'));
906 911
907 $crawler = $client->request('GET', '/unread/list'); 912 $crawler = $client->request('GET', '/unread/list');
908 $form = $crawler->filter('button[id=submit-filter]')->form(); 913 $form = $crawler->filter('button[id=submit-filter]')->form();
@@ -911,7 +916,7 @@ class EntryControllerTest extends WallabagCoreTestCase
911 ]; 916 ];
912 917
913 $crawler = $client->submit($form, $data); 918 $crawler = $client->submit($form, $data);
914 $this->assertCount(5, $crawler->filter('div[class=entry]')); 919 $this->assertCount(5, $crawler->filter('li.entry'));
915 920
916 $form = $crawler->filter('button[id=submit-filter]')->form(); 921 $form = $crawler->filter('button[id=submit-filter]')->form();
917 $data = [ 922 $data = [
@@ -919,13 +924,12 @@ class EntryControllerTest extends WallabagCoreTestCase
919 ]; 924 ];
920 925
921 $crawler = $client->submit($form, $data); 926 $crawler = $client->submit($form, $data);
922 $this->assertCount(0, $crawler->filter('div[class=entry]')); 927 $this->assertCount(0, $crawler->filter('li.entry'));
923 } 928 }
924 929
925 public function testFilterOnStatus() 930 public function testFilterOnStatus()
926 { 931 {
927 $this->logInAs('admin'); 932 $this->logInAs('admin');
928 $this->useTheme('baggy');
929 $client = $this->getClient(); 933 $client = $this->getClient();
930 934
931 $crawler = $client->request('GET', '/unread/list'); 935 $crawler = $client->request('GET', '/unread/list');
@@ -934,20 +938,19 @@ class EntryControllerTest extends WallabagCoreTestCase
934 $form['entry_filter[isStarred]']->untick(); 938 $form['entry_filter[isStarred]']->untick();
935 939
936 $crawler = $client->submit($form); 940 $crawler = $client->submit($form);
937 $this->assertCount(1, $crawler->filter('div[class=entry]')); 941 $this->assertCount(1, $crawler->filter('li.entry'));
938 942
939 $form = $crawler->filter('button[id=submit-filter]')->form(); 943 $form = $crawler->filter('button[id=submit-filter]')->form();
940 $form['entry_filter[isArchived]']->untick(); 944 $form['entry_filter[isArchived]']->untick();
941 $form['entry_filter[isStarred]']->tick(); 945 $form['entry_filter[isStarred]']->tick();
942 946
943 $crawler = $client->submit($form); 947 $crawler = $client->submit($form);
944 $this->assertCount(1, $crawler->filter('div[class=entry]')); 948 $this->assertCount(1, $crawler->filter('li.entry'));
945 } 949 }
946 950
947 public function testFilterOnIsPublic() 951 public function testFilterOnIsPublic()
948 { 952 {
949 $this->logInAs('admin'); 953 $this->logInAs('admin');
950 $this->useTheme('baggy');
951 $client = $this->getClient(); 954 $client = $this->getClient();
952 955
953 $crawler = $client->request('GET', '/unread/list'); 956 $crawler = $client->request('GET', '/unread/list');
@@ -955,13 +958,12 @@ class EntryControllerTest extends WallabagCoreTestCase
955 $form['entry_filter[isPublic]']->tick(); 958 $form['entry_filter[isPublic]']->tick();
956 959
957 $crawler = $client->submit($form); 960 $crawler = $client->submit($form);
958 $this->assertCount(0, $crawler->filter('div[class=entry]')); 961 $this->assertCount(0, $crawler->filter('li.entry'));
959 } 962 }
960 963
961 public function testPreviewPictureFilter() 964 public function testPreviewPictureFilter()
962 { 965 {
963 $this->logInAs('admin'); 966 $this->logInAs('admin');
964 $this->useTheme('baggy');
965 $client = $this->getClient(); 967 $client = $this->getClient();
966 968
967 $crawler = $client->request('GET', '/unread/list'); 969 $crawler = $client->request('GET', '/unread/list');
@@ -969,13 +971,12 @@ class EntryControllerTest extends WallabagCoreTestCase
969 $form['entry_filter[previewPicture]']->tick(); 971 $form['entry_filter[previewPicture]']->tick();
970 972
971 $crawler = $client->submit($form); 973 $crawler = $client->submit($form);
972 $this->assertCount(1, $crawler->filter('div[class=entry]')); 974 $this->assertCount(1, $crawler->filter('li.entry'));
973 } 975 }
974 976
975 public function testFilterOnLanguage() 977 public function testFilterOnLanguage()
976 { 978 {
977 $this->logInAs('admin'); 979 $this->logInAs('admin');
978 $this->useTheme('baggy');
979 $client = $this->getClient(); 980 $client = $this->getClient();
980 981
981 $entry = new Entry($this->getLoggedInUser()); 982 $entry = new Entry($this->getLoggedInUser());
@@ -991,7 +992,7 @@ class EntryControllerTest extends WallabagCoreTestCase
991 ]; 992 ];
992 993
993 $crawler = $client->submit($form, $data); 994 $crawler = $client->submit($form, $data);
994 $this->assertCount(3, $crawler->filter('div[class=entry]')); 995 $this->assertCount(3, $crawler->filter('li.entry'));
995 996
996 $form = $crawler->filter('button[id=submit-filter]')->form(); 997 $form = $crawler->filter('button[id=submit-filter]')->form();
997 $data = [ 998 $data = [
@@ -999,7 +1000,7 @@ class EntryControllerTest extends WallabagCoreTestCase
999 ]; 1000 ];
1000 1001
1001 $crawler = $client->submit($form, $data); 1002 $crawler = $client->submit($form, $data);
1002 $this->assertCount(2, $crawler->filter('div[class=entry]')); 1003 $this->assertCount(2, $crawler->filter('li.entry'));
1003 } 1004 }
1004 1005
1005 public function testShareEntryPublicly() 1006 public function testShareEntryPublicly()
@@ -1181,7 +1182,6 @@ class EntryControllerTest extends WallabagCoreTestCase
1181 public function testFilterOnHttpStatus() 1182 public function testFilterOnHttpStatus()
1182 { 1183 {
1183 $this->logInAs('admin'); 1184 $this->logInAs('admin');
1184 $this->useTheme('baggy');
1185 $client = $this->getClient(); 1185 $client = $this->getClient();
1186 1186
1187 $entry = new Entry($this->getLoggedInUser()); 1187 $entry = new Entry($this->getLoggedInUser());
@@ -1200,7 +1200,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1200 1200
1201 $crawler = $client->submit($form, $data); 1201 $crawler = $client->submit($form, $data);
1202 1202
1203 $this->assertCount(1, $crawler->filter('div[class=entry]')); 1203 $this->assertCount(1, $crawler->filter('li.entry'));
1204 1204
1205 $entry = new Entry($this->getLoggedInUser()); 1205 $entry = new Entry($this->getLoggedInUser());
1206 $entry->setUrl($this->url); 1206 $entry->setUrl($this->url);
@@ -1223,7 +1223,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1223 1223
1224 $crawler = $client->submit($form, $data); 1224 $crawler = $client->submit($form, $data);
1225 1225
1226 $this->assertCount(2, $crawler->filter('div[class=entry]')); 1226 $this->assertCount(2, $crawler->filter('li.entry'));
1227 1227
1228 $crawler = $client->request('GET', '/all/list'); 1228 $crawler = $client->request('GET', '/all/list');
1229 $form = $crawler->filter('button[id=submit-filter]')->form(); 1229 $form = $crawler->filter('button[id=submit-filter]')->form();
@@ -1234,13 +1234,12 @@ class EntryControllerTest extends WallabagCoreTestCase
1234 1234
1235 $crawler = $client->submit($form, $data); 1235 $crawler = $client->submit($form, $data);
1236 1236
1237 $this->assertCount(8, $crawler->filter('div[class=entry]')); 1237 $this->assertCount(8, $crawler->filter('li.entry'));
1238 } 1238 }
1239 1239
1240 public function testSearch() 1240 public function testSearch()
1241 { 1241 {
1242 $this->logInAs('admin'); 1242 $this->logInAs('admin');
1243 $this->useTheme('baggy');
1244 $client = $this->getClient(); 1243 $client = $this->getClient();
1245 1244
1246 $entry = new Entry($this->getLoggedInUser()); 1245 $entry = new Entry($this->getLoggedInUser());
@@ -1259,7 +1258,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1259 1258
1260 $crawler = $client->submit($form, $data); 1259 $crawler = $client->submit($form, $data);
1261 1260
1262 $this->assertCount(4, $crawler->filter('div[class=entry]')); 1261 $this->assertCount(4, $crawler->filter('li.entry'));
1263 1262
1264 // Search on starred list 1263 // Search on starred list
1265 $crawler = $client->request('GET', '/starred/list'); 1264 $crawler = $client->request('GET', '/starred/list');
@@ -1278,7 +1277,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1278 1277
1279 $crawler = $client->submit($form, $data); 1278 $crawler = $client->submit($form, $data);
1280 1279
1281 $this->assertCount(1, $crawler->filter('div[class=entry]')); 1280 $this->assertCount(1, $crawler->filter('li.entry'));
1282 1281
1283 $crawler = $client->request('GET', '/archive/list'); 1282 $crawler = $client->request('GET', '/archive/list');
1284 1283
@@ -1297,7 +1296,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1297 1296
1298 $crawler = $client->submit($form, $data); 1297 $crawler = $client->submit($form, $data);
1299 1298
1300 $this->assertCount(1, $crawler->filter('div[class=entry]')); 1299 $this->assertCount(1, $crawler->filter('li.entry'));
1301 $client->request('GET', '/delete/' . $entry->getId()); 1300 $client->request('GET', '/delete/' . $entry->getId());
1302 1301
1303 // test on list of all articles 1302 // test on list of all articles
@@ -1310,7 +1309,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1310 1309
1311 $crawler = $client->submit($form, $data); 1310 $crawler = $client->submit($form, $data);
1312 1311
1313 $this->assertCount(0, $crawler->filter('div[class=entry]')); 1312 $this->assertCount(0, $crawler->filter('li.entry'));
1314 1313
1315 // test url search on list of all articles 1314 // test url search on list of all articles
1316 $entry = new Entry($this->getLoggedInUser()); 1315 $entry = new Entry($this->getLoggedInUser());
@@ -1329,7 +1328,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1329 1328
1330 $crawler = $client->submit($form, $data); 1329 $crawler = $client->submit($form, $data);
1331 1330
1332 $this->assertCount(1, $crawler->filter('div[class=entry]')); 1331 $this->assertCount(1, $crawler->filter('li.entry'));
1333 1332
1334 // same as previous test but for case-sensitivity 1333 // same as previous test but for case-sensitivity
1335 $crawler = $client->request('GET', '/all/list'); 1334 $crawler = $client->request('GET', '/all/list');
@@ -1341,7 +1340,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1341 1340
1342 $crawler = $client->submit($form, $data); 1341 $crawler = $client->submit($form, $data);
1343 1342
1344 $this->assertCount(1, $crawler->filter('div[class=entry]')); 1343 $this->assertCount(1, $crawler->filter('li.entry'));
1345 } 1344 }
1346 1345
1347 public function dataForLanguage() 1346 public function dataForLanguage()