Skip to content

Commit c53bf3a

Browse files
committed
test(slovakia): fix excluded years in data providers
Return false from callbacks in OurLadyOfSorrowsDayTest and VictoryInEuropeDayTest to properly skip years 2025 and 2026; previously the bare return had no effect and excluded years could still appear in the generated test data. Signed-off-by: Sacha Telgenhof <me@sachatelgenhof.com>
1 parent e6ff097 commit c53bf3a

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

tests/Randomizer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,10 @@ public function generateRandomDatesWithModifier(
240240
$year = $this->generateRandomYear($range);
241241
$date = new \DateTime("{$year}-{$month}-{$day}", new \DateTimeZone($timezone ?? 'UTC'));
242242

243-
$callback($year, $date);
243+
if (false === $callback($year, $date)) {
244+
--$i;
245+
continue;
246+
}
244247

245248
$data[] = [$year, $date->format('Y-m-d')];
246249
}

tests/Slovakia/OurLadyOfSorrowsDayTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,13 @@ public function testHoliday(int $year, $expected): void
5656
*/
5757
public function HolidayDataProvider(): array
5858
{
59-
return $this->generateRandomDatesWithModifier(9, 15, function ($year, \DateTime $date): void {
59+
return $this->generateRandomDatesWithModifier(9, 15, function ($year, \DateTime $date): ?bool {
6060
// Our Lady of Sorrows Day is not observed in 2025 and 2026
6161
if (in_array($year, [2025, 2026])) {
62-
return;
62+
return false;
6363
}
64+
65+
return null;
6466
}, 5, 1000, self::TIMEZONE);
6567
}
6668

tests/Slovakia/VictoryInEuropeDayTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ public function testHoliday(int $year, string $expected): void
5959
*/
6060
public function HolidayDataProvider(): array
6161
{
62-
return $this->generateRandomDatesWithModifier(5, 8, function ($year, \DateTime $date): void {
62+
return $this->generateRandomDatesWithModifier(5, 8, function ($year, \DateTime $date): ?bool {
6363
// Victory in Europe Day is not observed in 2025 and 2026
6464
if (in_array($year, [2025, 2026])) {
65-
return;
65+
return false;
6666
}
67+
68+
return null;
6769
}, 5, 1000, self::TIMEZONE);
6870
}
6971

0 commit comments

Comments
 (0)