Skip to content

Commit

Permalink
[TASK] Add additional unit test for calendar service week config
Browse files Browse the repository at this point in the history
  • Loading branch information
derhansen committed Dec 14, 2024
1 parent 1445a80 commit 8738dce
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/UnitTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['8.2', '8.3']
php: ['8.2', '8.3', '8.4']

steps:
- uses: actions/checkout@v3
Expand Down
55 changes: 40 additions & 15 deletions Tests/Unit/Service/CalendarServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,26 +243,51 @@ public function getDateConfigReturnsExpectedValues(int $month, int $year, string
self::assertEquals($expected, $result);
}

#[Test]
public function getWeekConfigReturnsExpectedValue(): void
public static function weekConfigDataProvider(): array
{
$firstDayOfWeek = DateTime::createFromFormat('d.m.Y', '3.1.2022')->setTime(0, 0);

$expected = [
'previous' => [
'weeknumber' => 52,
'year' => 2021,
],
'current' => [
'weeknumber' => 1,
'year' => 2022,
return [
'3.1.2022' => [
'3.1.2022',
[
'previous' => [
'weeknumber' => 52,
'year' => 2021,
],
'current' => [
'weeknumber' => 1,
'year' => 2022,
],
'next' => [
'weeknumber' => 2,
'year' => 2022,
],
]
],
'next' => [
'weeknumber' => 2,
'year' => 2022,
'30.12.2024' => [
'30.12.2024',
[
'previous' => [
'weeknumber' => 52,
'year' => 2024,
],
'current' => [
'weeknumber' => 1,
'year' => 2025,
],
'next' => [
'weeknumber' => 2,
'year' => 2025,
],
]
],
];
}

#[DataProvider('weekConfigDataProvider')]
#[Test]
public function getWeekConfigReturnsExpectedValue(string $date, array $expected): void
{
$firstDayOfWeek = DateTime::createFromFormat('d.m.Y', $date)->setTime(0, 0);
self::assertEquals($expected, $this->subject->getWeekConfig($firstDayOfWeek));
}
}

0 comments on commit 8738dce

Please sign in to comment.