mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 13:03:50 +00:00
Update ReferrerAggregator to specify a date range as parameter
The ReferrerAggregator in ChillPersonBundle has been updated to include start and end dates, replacing the previous single computation date. This provides greater flexibility in setting the timeframe for referrer data. The messages.fr.yml file has also been updated to reflect these changes. Relevant tests have been updated to match the new functionality.
This commit is contained in:
@@ -33,7 +33,40 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest
|
||||
$this->aggregator = self::$container->get('chill.person.export.aggregator_referrer');
|
||||
}
|
||||
|
||||
public function getAggregator()
|
||||
/**
|
||||
* @dataProvider provideBeforeData
|
||||
*/
|
||||
public function testDataTransformer(?array $before, array $expected): void
|
||||
{
|
||||
$actual = $this->getAggregator()->transformData($before);
|
||||
|
||||
self::assertEqualsCanonicalizing(array_keys($expected), array_keys($actual));
|
||||
foreach (['start_date', 'end_date'] as $key) {
|
||||
self::assertInstanceOf(RollingDate::class, $actual[$key]);
|
||||
self::assertEquals($expected[$key]->getRoll(), $actual[$key]->getRoll(), "Check that the roll is the same for {$key}");
|
||||
}
|
||||
}
|
||||
|
||||
public function provideBeforeData(): iterable
|
||||
{
|
||||
yield [
|
||||
['date_calc' => new RollingDate(RollingDate::T_TODAY)],
|
||||
['start_date' => new RollingDate(RollingDate::T_TODAY), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
|
||||
yield [
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
['start_date' => new RollingDate(RollingDate::T_WEEK_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
|
||||
yield [
|
||||
null,
|
||||
// this is the default configuration
|
||||
['start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START), 'end_date' => new RollingDate(RollingDate::T_TODAY)],
|
||||
];
|
||||
}
|
||||
|
||||
public function getAggregator(): ReferrerAggregator
|
||||
{
|
||||
return $this->aggregator;
|
||||
}
|
||||
@@ -41,7 +74,10 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest
|
||||
public function getFormData(): array
|
||||
{
|
||||
return [
|
||||
['date_calc' => new RollingDate(RollingDate::T_TODAY)],
|
||||
[
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user