mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-23 09:31:04 +00:00
Add test for same day filter
This commit is contained in:
parent
7d6c3edcdd
commit
f90af145ca
2 changed files with 14 additions and 5 deletions
|
@ -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
|
||||
{
|
||||
|
@ -22,12 +22,12 @@ class CustomDoctrineORMSubscriber extends DoctrineORMSubscriber implements Event
|
|||
$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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue