-
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.
- Loading branch information
Christian Kolb
committed
Jun 9, 2024
1 parent
7969ee8
commit bb7c663
Showing
3 changed files
with
152 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DigitalCraftsman\DateTimePrecision\Weekdays; | ||
|
||
use DigitalCraftsman\DateTimePrecision\Weekday; | ||
use DigitalCraftsman\DateTimePrecision\Weekdays; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** @coversDefaultClass \DigitalCraftsman\DateTimePrecision\Weekdays */ | ||
final class ContainsTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* | ||
* @dataProvider dataProvider | ||
* | ||
* @covers ::contains | ||
*/ | ||
public function contain_works( | ||
bool $expectedResult, | ||
Weekdays $weekdays, | ||
Weekday $comparator, | ||
): void { | ||
// -- Act & Assert | ||
self::assertSame($expectedResult, $weekdays->contains($comparator)); | ||
} | ||
|
||
/** | ||
* @return array<string, array{ | ||
* 0: bool, | ||
* 1: Weekdays, | ||
* 2: Weekday, | ||
* }> | ||
*/ | ||
public static function dataProvider(): array | ||
{ | ||
return [ | ||
'tuesday' => [ | ||
true, | ||
new Weekdays([ | ||
Weekday::TUESDAY, | ||
Weekday::WEDNESDAY, | ||
]), | ||
Weekday::TUESDAY, | ||
], | ||
'thursday' => [ | ||
false, | ||
new Weekdays([ | ||
Weekday::MONDAY, | ||
Weekday::WEDNESDAY, | ||
]), | ||
Weekday::THURSDAY, | ||
], | ||
]; | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DigitalCraftsman\DateTimePrecision\Weekdays; | ||
|
||
use DigitalCraftsman\DateTimePrecision\Weekday; | ||
use DigitalCraftsman\DateTimePrecision\Weekdays; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** @coversDefaultClass \DigitalCraftsman\DateTimePrecision\Weekdays */ | ||
final class NormalizationTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* | ||
* @covers ::normalize | ||
* @covers ::denormalize | ||
*/ | ||
public function normalize_works(): void | ||
{ | ||
// -- Arrange | ||
$weekdays = new Weekdays([ | ||
Weekday::MONDAY, | ||
Weekday::TUESDAY, | ||
]); | ||
|
||
// -- Act | ||
$normalizedWeekdays = $weekdays->normalize(); | ||
$denormalizedWeekdays = Weekdays::denormalize($normalizedWeekdays); | ||
|
||
// -- Assert | ||
self::assertEquals($weekdays, $denormalizedWeekdays); | ||
} | ||
} |
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,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DigitalCraftsman\DateTimePrecision\Weekdays; | ||
|
||
use DigitalCraftsman\DateTimePrecision\Weekday; | ||
use DigitalCraftsman\DateTimePrecision\Weekdays; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** @coversDefaultClass \DigitalCraftsman\DateTimePrecision\Weekdays */ | ||
final class NotContainsTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* | ||
* @dataProvider dataProvider | ||
* | ||
* @covers ::notContains | ||
*/ | ||
public function not_contain_works( | ||
bool $expectedResult, | ||
Weekdays $weekdays, | ||
Weekday $comparator, | ||
): void { | ||
// -- Act & Assert | ||
self::assertSame($expectedResult, $weekdays->notContains($comparator)); | ||
} | ||
|
||
/** | ||
* @return array<string, array{ | ||
* 0: bool, | ||
* 1: Weekdays, | ||
* 2: Weekday, | ||
* }> | ||
*/ | ||
public static function dataProvider(): array | ||
{ | ||
return [ | ||
'tuesday' => [ | ||
true, | ||
new Weekdays([ | ||
Weekday::MONDAY, | ||
Weekday::WEDNESDAY, | ||
]), | ||
Weekday::TUESDAY, | ||
], | ||
'thursday' => [ | ||
false, | ||
new Weekdays([ | ||
Weekday::MONDAY, | ||
Weekday::WEDNESDAY, | ||
Weekday::THURSDAY, | ||
]), | ||
Weekday::THURSDAY, | ||
], | ||
]; | ||
} | ||
} |