diff options
-rw-r--r-- | src/Wallabag/CoreBundle/Event/Subscriber/CustomDoctrineORMSubscriber.php | 10 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | 9 |
2 files changed, 14 insertions, 5 deletions
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; | |||
8 | 8 | ||
9 | /** | 9 | /** |
10 | * This custom class override the default behavior of LexikFilterBundle on `filter_date_range` | 10 | * This custom class override the default behavior of LexikFilterBundle on `filter_date_range` |
11 | * 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) | 11 | * 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). |
12 | */ | 12 | */ |
13 | class CustomDoctrineORMSubscriber extends DoctrineORMSubscriber implements EventSubscriberInterface | 13 | class CustomDoctrineORMSubscriber extends DoctrineORMSubscriber implements EventSubscriberInterface |
14 | { | 14 | { |
@@ -17,17 +17,17 @@ class CustomDoctrineORMSubscriber extends DoctrineORMSubscriber implements Event | |||
17 | */ | 17 | */ |
18 | public function filterDateRange(GetFilterConditionEvent $event) | 18 | public function filterDateRange(GetFilterConditionEvent $event) |
19 | { | 19 | { |
20 | $expr = $event->getFilterQuery()->getExpressionBuilder(); | 20 | $expr = $event->getFilterQuery()->getExpressionBuilder(); |
21 | $values = $event->getValues(); | 21 | $values = $event->getValues(); |
22 | $value = $values['value']; | 22 | $value = $values['value']; |
23 | 23 | ||
24 | // left date should start at midnight | 24 | // left date should start at midnight |
25 | if (isset($value['left_date'][0]) && $value['left_date'][0] instanceOf \DateTime) { | 25 | if (isset($value['left_date'][0]) && $value['left_date'][0] instanceof \DateTime) { |
26 | $value['left_date'][0]->setTime(0, 0, 0); | 26 | $value['left_date'][0]->setTime(0, 0, 0); |
27 | } | 27 | } |
28 | 28 | ||
29 | // right adte should end one second before midnight | 29 | // right adte should end one second before midnight |
30 | if (isset($value['right_date'][0]) && $value['right_date'][0] instanceOf \DateTime) { | 30 | if (isset($value['right_date'][0]) && $value['right_date'][0] instanceof \DateTime) { |
31 | $value['right_date'][0]->setTime(23, 59, 59); | 31 | $value['right_date'][0]->setTime(23, 59, 59); |
32 | } | 32 | } |
33 | 33 | ||
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 | |||
@@ -279,6 +279,15 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
279 | $this->assertCount(5, $crawler->filter('div[class=entry]')); | 279 | $this->assertCount(5, $crawler->filter('div[class=entry]')); |
280 | 280 | ||
281 | $data = array( | 281 | $data = array( |
282 | 'entry_filter[createdAt][left_date]' => date('d/m/Y'), | ||
283 | 'entry_filter[createdAt][right_date]' => date('d/m/Y'), | ||
284 | ); | ||
285 | |||
286 | $crawler = $client->submit($form, $data); | ||
287 | |||
288 | $this->assertCount(5, $crawler->filter('div[class=entry]')); | ||
289 | |||
290 | $data = array( | ||
282 | 'entry_filter[createdAt][left_date]' => '01/01/1970', | 291 | 'entry_filter[createdAt][left_date]' => '01/01/1970', |
283 | 'entry_filter[createdAt][right_date]' => '01/01/1970', | 292 | 'entry_filter[createdAt][right_date]' => '01/01/1970', |
284 | ); | 293 | ); |