mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix tests
This commit is contained in:
parent
f807d62dab
commit
4129283a58
@ -70,11 +70,19 @@ final readonly class ReferrerAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function normalizeFormData(array $formData): array
|
public function normalizeFormData(array $formData): array
|
||||||
{
|
{
|
||||||
|
if (!array_key_exists('referrer_at', $formData)) {
|
||||||
|
return ['referrer_at' => (new RollingDate(RollingDate::T_TODAY))->normalize()];
|
||||||
|
}
|
||||||
|
|
||||||
return ['referrer_at' => $formData['referrer_at']->normalize()];
|
return ['referrer_at' => $formData['referrer_at']->normalize()];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function denormalizeFormData(array $formData, int $fromVersion): array
|
public function denormalizeFormData(array $formData, int $fromVersion): array
|
||||||
{
|
{
|
||||||
|
if (!array_key_exists('referrer_at', $formData)) {
|
||||||
|
return ['referrer_at' => new RollingDate(RollingDate::T_TODAY)];
|
||||||
|
}
|
||||||
|
|
||||||
return ['referrer_at' => RollingDate::fromNormalized($formData['referrer_at'])];
|
return ['referrer_at' => RollingDate::fromNormalized($formData['referrer_at'])];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,4 +60,29 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest
|
|||||||
->from(AccompanyingPeriodWork::class, 'acpw'),
|
->from(AccompanyingPeriodWork::class, 'acpw'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of data to normalize.
|
||||||
|
*
|
||||||
|
* @return iterable{array}
|
||||||
|
*/
|
||||||
|
public static function dataProviderFormDataToNormalize(): iterable
|
||||||
|
{
|
||||||
|
foreach (self::getFormData() as $data) {
|
||||||
|
yield [$data, 1, []];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider dataProviderFormDataToNormalize
|
||||||
|
*/
|
||||||
|
public function testDataNormalization(array $data, int $version, array $customAssert): void
|
||||||
|
{
|
||||||
|
$aggregator = $this->getAggregator();
|
||||||
|
|
||||||
|
$normalized = $aggregator->normalizeFormData($data);
|
||||||
|
$actual = $aggregator->denormalizeFormData($normalized, $version);
|
||||||
|
|
||||||
|
self::assertIsArray($actual);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user