From 8ee7b1603d23297a6c183105f79b1290ce9828bf Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sat, 21 Mar 2020 21:11:01 +0100 Subject: Fix createdAt date range filter - hiddenName has been disabled in order to fix the missing date range values when using the material theme - data format has been changed to 'Y-m-d' in order to comply with the browser date input default format - tests: date() and strtotime have been replaced with DateTime-related objects Signed-off-by: Kevin Decherf --- .../CoreBundle/Controller/EntryControllerTest.php | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 29d15eea..3dcc1cd0 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -822,13 +822,25 @@ class EntryControllerTest extends WallabagCoreTestCase $this->logInAs('admin'); $client = $this->getClient(); + $em = $this->getEntityManager(); + + $today = new \DateTimeImmutable(); + $tomorrow = $today->add(new \DateInterval('P1D')); + $yesterday = $today->sub(new \DateInterval('P1D')); + + $entry = new Entry($this->getLoggedInUser()); + $entry->setUrl('http://0.0.0.0/testFilterOnCreationDate'); + $entry->setCreatedAt($yesterday); + $em->persist($entry); + $em->flush(); + $crawler = $client->request('GET', '/unread/list'); $form = $crawler->filter('button[id=submit-filter]')->form(); $data = [ - 'entry_filter[createdAt][left_date]' => date('d/m/Y'), - 'entry_filter[createdAt][right_date]' => date('d/m/Y', strtotime('+1 day')), + 'entry_filter[createdAt][left_date]' => $today->format('Y-m-d'), + 'entry_filter[createdAt][right_date]' => $tomorrow->format('Y-m-d'), ]; $crawler = $client->submit($form, $data); @@ -836,8 +848,8 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertCount(5, $crawler->filter('li.entry')); $data = [ - 'entry_filter[createdAt][left_date]' => date('d/m/Y'), - 'entry_filter[createdAt][right_date]' => date('d/m/Y'), + 'entry_filter[createdAt][left_date]' => $today->format('Y-m-d'), + 'entry_filter[createdAt][right_date]' => $today->format('Y-m-d'), ]; $crawler = $client->submit($form, $data); @@ -845,8 +857,8 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertCount(5, $crawler->filter('li.entry')); $data = [ - 'entry_filter[createdAt][left_date]' => '01/01/1970', - 'entry_filter[createdAt][right_date]' => '01/01/1970', + 'entry_filter[createdAt][left_date]' => '1970-01-01', + 'entry_filter[createdAt][right_date]' => '1970-01-01', ]; $crawler = $client->submit($form, $data); -- cgit v1.2.3