Add unit test to MatomoSendVisitsCommand

This commit is contained in:
Alejandro Celaya
2024-04-13 20:30:00 +02:00
parent bbdbafd8db
commit f0e62004d5
4 changed files with 183 additions and 36 deletions

View File

@@ -61,6 +61,23 @@ function parseDateRangeFromQuery(array $query, string $startDateName, string $en
return buildDateRange($startDate, $endDate);
}
function dateRangeToHumanFriendly(?DateRange $dateRange): string
{
$startDate = $dateRange?->startDate;
$endDate = $dateRange?->endDate;
return match (true) {
$startDate !== null && $endDate !== null => sprintf(
'Between %s and %s',
$startDate->toDateTimeString(),
$endDate->toDateTimeString(),
),
$startDate !== null => sprintf('Since %s', $startDate->toDateTimeString()),
$endDate !== null => sprintf('Until %s', $endDate->toDateTimeString()),
default => 'All time',
};
}
/**
* @return ($date is null ? null : Chronos)
*/