8000 Fix date for dynamic contents by kuzmany · Pull Request #9955 · mautic/mautic · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix date for dynamic contents #9955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 9, 2021
10 changes: 0 additions & 10 deletions app/bundles/EmailBundle/EventListener/MatchFilterForLeadTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ protected function matchFilterForLead(array $filter, array $lead)
// Lead in generated for preview with faked data
return false;
}

$groups = [];
$groupNum = 0;

Expand Down Expand Up @@ -76,15 +75,6 @@ protected function matchFilterForLead(array $filter, array $lead)
$filterVal = (bool) $filterVal;
}
break;
case 'date':
10204 if (!$leadVal instanceof \DateTime) {
$leadVal = new \DateTime($leadVal);
}

if (!$filterVal instanceof \DateTime) {
$filterVal = new \DateTime($filterVal);
}
break;
case 'datetime':
case 'time':
$leadValCount = substr_count($leadVal, ':');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,45 @@ public function testDWCContactContains(): void

self::assertFalse($this->matchFilterForLeadTrait->match($this->filter, $this->lead));
}

/**
* @dataProvider dateMatchTestProvider
*/
public function testMatchFilterForLeadTraitForDate(?string $value, string $operator, bool $expect)
{
$filters = [
[
'glue' => 'and',
'field' => 'date',
'object' => 'lead',
'type' => 'date',
'filter' => '2021-05-01',
'display' => null,
'operator' => $operator,
],
];

$lead = [
'id' => 1,
'date' => $value,
];

$this->assertEquals($expect, $this->matchFilterForLeadTrait->match($filters, $lead));
}

public function dateMatchTestProvider(): iterable
{
$date = '2021-05-01';

yield [$date, '=', true];
yield [$date, '!=', false];
yield ['2020-02-02', '!=', true];
yield [$date, '!=', false];
yield [null, 'empty', true];
yield [$date, 'empty', false];
yield [$date, '!empty', true];
yield [null, '!empty', false];
}
}

class MatchFilterForLeadTraitTestable
Expand Down
0