-
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
Sep 20, 2023
1 parent
74a37a3
commit 915b7d3
Showing
2 changed files
with
71 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
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,66 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DigitalCraftsman\DateTimeParts\Date; | ||
|
||
use DigitalCraftsman\DateTimeParts\Date; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** @coversDefaultClass \DigitalCraftsman\DateTimeParts\Date */ | ||
final class IsNotBeforeTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* | ||
* @dataProvider dataProvider | ||
* | ||
* @covers ::isNotBefore | ||
*/ | ||
public function is_not_before_works( | ||
bool $expectedResult, | ||
Date $date, | ||
Date $comparator, | ||
): void { | ||
// -- Act & Assert | ||
self::assertSame($expectedResult, $date->isNotBefore($comparator)); | ||
} | ||
|
||
/** | ||
* @return array<string, array{ | ||
* 0: boolean, | ||
* 1: Date, | ||
* 2: Date, | ||
* }> | ||
*/ | ||
public function dataProvider(): array | ||
{ | ||
return [ | ||
'previous year' => [ | ||
true, | ||
Date::fromString('2022-10-08'), | ||
Date::fromString('2021-10-08'), | ||
], | ||
'same date' => [ | ||
true, | ||
Date::fromString('2022-10-08'), | ||
Date::fromString('2022-10-08'), | ||
], | ||
'next year' => [ | ||
false, | ||
Date::fromString('2022-10-08'), | ||
Date::fromString('2023-10-08'), | ||
], | ||
'next month' => [ | ||
false, | ||
Date::fromString('2022-10-08'), | ||
Date::fromString('2022-11-08'), | ||
], | ||
'next day' => [ | ||
false, | ||
Date::fromString('2022-10-08'), | ||
Date::fromString('2022-10-09'), | ||
], | ||
]; | ||
} | ||
} |