39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Event;
|
|
|
|
use App\Domains\Event\Services\EventDateTextFormatter;
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class EventDateTextFormatterTest extends TestCase
|
|
{
|
|
/** @param array<int, string> $dates */
|
|
#[DataProvider('dateCases')]
|
|
public function test_it_formats_event_dates_in_spanish(array $dates, ?string $expected): void
|
|
{
|
|
$this->assertSame($expected, (new EventDateTextFormatter)->format($dates));
|
|
}
|
|
|
|
/** @return array<string, array{array<int, string>, string|null}> */
|
|
public static function dateCases(): array
|
|
{
|
|
return [
|
|
'no dates' => [[], null],
|
|
'one date' => [['2026-10-09'], '9 de Octubre 2026'],
|
|
'same month sorted' => [
|
|
['2026-10-12', '2026-10-09', '2026-10-11', '2026-10-10'],
|
|
'9, 10, 11 y 12 de Octubre 2026',
|
|
],
|
|
'different months' => [
|
|
['2026-11-01', '2026-10-31'],
|
|
'31 de Octubre y 1 de Noviembre 2026',
|
|
],
|
|
'different years' => [
|
|
['2027-01-01', '2026-12-31'],
|
|
'31 de Diciembre 2026 y 1 de Enero 2027',
|
|
],
|
|
];
|
|
}
|
|
}
|