From f90af145caa040d17f2fb01e78b645c4157c3781 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 23 Aug 2015 22:06:27 +0200 Subject: Add test for same day filter --- .../Event/Subscriber/CustomDoctrineORMSubscriber.php | 10 +++++----- .../CoreBundle/Tests/Controller/EntryControllerTest.php | 9 +++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Event/Subscriber/CustomDoctrineORMSubscriber.php b/src/Wallabag/CoreBundle/Event/Subscriber/CustomDoctrineORMSubscriber.php index 20ced679..cfdbfe97 100644 --- a/src/Wallabag/CoreBundle/Event/Subscriber/CustomDoctrineORMSubscriber.php +++ b/src/Wallabag/CoreBundle/Event/Subscriber/CustomDoctrineORMSubscriber.php @@ -8,7 +8,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * This custom class override the default behavior of LexikFilterBundle on `filter_date_range` - * It converts a date_range to date_time_range to add hour to be able to grab a whole day (from 00:00:00 to 23:59:59) + * It converts a date_range to date_time_range to add hour to be able to grab a whole day (from 00:00:00 to 23:59:59). */ class CustomDoctrineORMSubscriber extends DoctrineORMSubscriber implements EventSubscriberInterface { @@ -17,17 +17,17 @@ class CustomDoctrineORMSubscriber extends DoctrineORMSubscriber implements Event */ public function filterDateRange(GetFilterConditionEvent $event) { - $expr = $event->getFilterQuery()->getExpressionBuilder(); + $expr = $event->getFilterQuery()->getExpressionBuilder(); $values = $event->getValues(); - $value = $values['value']; + $value = $values['value']; // left date should start at midnight - if (isset($value['left_date'][0]) && $value['left_date'][0] instanceOf \DateTime) { + if (isset($value['left_date'][0]) && $value['left_date'][0] instanceof \DateTime) { $value['left_date'][0]->setTime(0, 0, 0); } // right adte should end one second before midnight - if (isset($value['right_date'][0]) && $value['right_date'][0] instanceOf \DateTime) { + if (isset($value['right_date'][0]) && $value['right_date'][0] instanceof \DateTime) { $value['right_date'][0]->setTime(23, 59, 59); } diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 5f0a6076..a0966285 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -278,6 +278,15 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertCount(5, $crawler->filter('div[class=entry]')); + $data = array( + 'entry_filter[createdAt][left_date]' => date('d/m/Y'), + 'entry_filter[createdAt][right_date]' => date('d/m/Y'), + ); + + $crawler = $client->submit($form, $data); + + $this->assertCount(5, $crawler->filter('div[class=entry]')); + $data = array( 'entry_filter[createdAt][left_date]' => '01/01/1970', 'entry_filter[createdAt][right_date]' => '01/01/1970', -- cgit v1.2.3