-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unnecessary method and extend test coverage
- Loading branch information
Christian Kolb
committed
Jun 9, 2024
1 parent
dfde9bc
commit f533051
Showing
4 changed files
with
132 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DigitalCraftsman\DateTimePrecision\Weekday; | ||
|
||
use DigitalCraftsman\DateTimePrecision\Weekday; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** @coversDefaultClass \DigitalCraftsman\DateTimePrecision\Weekday */ | ||
final class CompareToTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* | ||
* @dataProvider dataProvider | ||
* | ||
* @covers ::compareTo | ||
*/ | ||
public function compare_to_works( | ||
int $expectedResult, | ||
Weekday $weekday, | ||
Weekday $comparator, | ||
): void { | ||
// -- Act & Assert | ||
self::assertSame($expectedResult, $weekday->compareTo($comparator)); | ||
} | ||
|
||
/** | ||
* @return array<string, array{ | ||
* 0: int, | ||
* 1: Weekday, | ||
* 2: Weekday, | ||
* }> | ||
*/ | ||
public static function dataProvider(): array | ||
{ | ||
return [ | ||
'1 weekday later' => [ | ||
1, | ||
Weekday::THURSDAY, | ||
Weekday::WEDNESDAY, | ||
], | ||
'same weekday' => [ | ||
0, | ||
Weekday::SATURDAY, | ||
Weekday::SATURDAY, | ||
], | ||
'1 weekday before' => [ | ||
-1, | ||
Weekday::TUESDAY, | ||
Weekday::WEDNESDAY, | ||
], | ||
'2 weekdays before' => [ | ||
-1, | ||
Weekday::MONDAY, | ||
Weekday::WEDNESDAY, | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DigitalCraftsman\DateTimePrecision\Weekday; | ||
|
||
use DigitalCraftsman\DateTimePrecision\Moment; | ||
use DigitalCraftsman\DateTimePrecision\Weekday; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** @coversDefaultClass \DigitalCraftsman\DateTimePrecision\Weekday */ | ||
final class ConstructionTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* | ||
* @dataProvider dataProvider | ||
* | ||
* @covers ::fromDateTime | ||
*/ | ||
public function from_date_time_works( | ||
Weekday $expectedResult, | ||
Moment $moment, | ||
): void { | ||
// -- Act & Assert | ||
self::assertTrue($expectedResult->isEqualTo(Weekday::fromDateTime($moment->dateTime))); | ||
} | ||
|
||
/** | ||
* @return array<string, array{ | ||
* 0: Weekday, | ||
* 1: Moment, | ||
* }> | ||
*/ | ||
public static function dataProvider(): array | ||
{ | ||
return [ | ||
'monday' => [ | ||
Weekday::MONDAY, | ||
Moment::fromString('2022-10-10 22:15:00'), | ||
], | ||
'tuesday' => [ | ||
Weekday::TUESDAY, | ||
Moment::fromString('2022-10-11 22:15:00'), | ||
], | ||
'wednesday' => [ | ||
Weekday::WEDNESDAY, | ||
Moment::fromString('2022-10-12 22:15:00'), | ||
], | ||
'thursday' => [ | ||
Weekday::THURSDAY, | ||
Moment::fromString('2022-10-13 22:15:00'), | ||
], | ||
'friday' => [ | ||
Weekday::FRIDAY, | ||
Moment::fromString('2022-10-14 22:15:00'), | ||
], | ||
'saturday' => [ | ||
Weekday::SATURDAY, | ||
Moment::fromString('2022-10-15 22:15:00'), | ||
], | ||
'sunday' => [ | ||
Weekday::SUNDAY, | ||
Moment::fromString('2022-10-16 22:15:00'), | ||
], | ||
]; | ||
} | ||
} |