-
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.
Add tests and remove milliseconds from time
- Loading branch information
Christian Kolb
committed
Dec 7, 2024
1 parent
7528990
commit db62f6f
Showing
7 changed files
with
186 additions
and
2 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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DigitalCraftsman\DateTimePrecision\Month; | ||
|
||
use DigitalCraftsman\DateTimePrecision\Month; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @coversDefaultClass \DigitalCraftsman\DateTimePrecision\Month | ||
*/ | ||
final class NormalizeDenormalizeTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* | ||
* @covers ::normalize | ||
* @covers ::denormalize | ||
*/ | ||
public function normalize_and_denormalize_works(): void | ||
{ | ||
// -- Arrange | ||
$month = Month::fromString('2022-10'); | ||
$data = '2022-10'; | ||
|
||
// -- Act | ||
$normalized = $month->normalize(); | ||
$denormalized = Month::denormalize($data); | ||
|
||
// -- Assert | ||
self::assertSame($data, $normalized); | ||
self::assertEquals($month, $denormalized); | ||
} | ||
} |
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\Time; | ||
|
||
use DigitalCraftsman\DateTimePrecision\Time; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @coversDefaultClass \DigitalCraftsman\DateTimePrecision\Time | ||
*/ | ||
final class NormalizeDenormalizeTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* | ||
* @covers ::normalize | ||
* @covers ::denormalize | ||
*/ | ||
public function normalize_and_denormalize_works(): void | ||
{ | ||
// -- Arrange | ||
$time = Time::fromString('15:45:30'); | ||
$data = '15:45:30'; | ||
|
||
// -- Act | ||
$normalized = $time->normalize(); | ||
$denormalized = Time::denormalize($data); | ||
|
||
// -- Assert | ||
self::assertSame($data, $normalized); | ||
self::assertEquals($time, $denormalized); | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DigitalCraftsman\DateTimePrecision\Weekday; | ||
|
||
use DigitalCraftsman\DateTimePrecision\Weekday; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @coversDefaultClass \DigitalCraftsman\DateTimePrecision\Weekday | ||
*/ | ||
final class NormalizeDenormalizeTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* | ||
* @covers ::normalize | ||
* @covers ::denormalize | ||
*/ | ||
public function normalize_and_denormalize_works(): void | ||
{ | ||
// -- Arrange | ||
$weekday = Weekday::MONDAY; | ||
$data = 'MONDAY'; | ||
|
||
// -- Act | ||
$normalized = $weekday->normalize(); | ||
$denormalized = Weekday::denormalize($data); | ||
|
||
// -- Assert | ||
self::assertSame($data, $normalized); | ||
self::assertEquals($weekday, $denormalized); | ||
} | ||
} |
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,44 @@ | ||
<?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 NormalizeDenormalizeTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* | ||
* @covers ::normalize | ||
* @covers ::denormalize | ||
*/ | ||
public function normalize_and_denormalize_works(): void | ||
{ | ||
// -- Arrange | ||
$weekdays = new Weekdays([ | ||
Weekday::MONDAY, | ||
Weekday::TUESDAY, | ||
Weekday::WEDNESDAY, | ||
]); | ||
$data = [ | ||
'MONDAY', | ||
'TUESDAY', | ||
'WEDNESDAY', | ||
]; | ||
|
||
// -- Act | ||
$normalized = $weekdays->normalize(); | ||
$denormalized = Weekdays::denormalize($data); | ||
|
||
// -- Assert | ||
self::assertSame($data, $normalized); | ||
self::assertEquals($weekdays, $denormalized); | ||
} | ||
} |
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\Year; | ||
|
||
use DigitalCraftsman\DateTimePrecision\Year; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @coversDefaultClass \DigitalCraftsman\DateTimePrecision\Year | ||
*/ | ||
final class NormalizeDenormalizeTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* | ||
* @covers ::normalize | ||
* @covers ::denormalize | ||
*/ | ||
public function normalize_and_denormalize_works(): void | ||
{ | ||
// -- Arrange | ||
$year = Year::fromString('2022'); | ||
$data = 2022; | ||
|
||
// -- Act | ||
$normalized = $year->normalize(); | ||
$denormalized = Year::denormalize($data); | ||
|
||
// -- Assert | ||
self::assertSame($data, $normalized); | ||
self::assertEquals($year, $denormalized); | ||
} | ||
} |