Skip to content

Commit

Permalink
Finalize coverage of is methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Kolb committed Jun 9, 2024
1 parent 3b9101a commit dfde9bc
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/Weekday/IsAfterTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

namespace DigitalCraftsman\DateTimePrecision\Weekday;

use DigitalCraftsman\DateTimePrecision\Weekday;
use PHPUnit\Framework\TestCase;

/** @coversDefaultClass \DigitalCraftsman\DateTimePrecision\Weekday */
final class IsAfterTest extends TestCase
{
/**
* @test
*
* @dataProvider dataProvider
*
* @covers ::isAfter
*/
public function is_after_works(
bool $expectedResult,
Weekday $weekday,
Weekday $comparator,
): void {
// -- Act & Assert
self::assertSame($expectedResult, $weekday->isAfter($comparator));
}

/**
* @return array<string, array{
* 0: boolean,
* 1: Weekday,
* 2: Weekday,
* }>
*/
public static function dataProvider(): array
{
return [
'1 day before' => [
false,
Weekday::MONDAY,
Weekday::TUESDAY,
],
'same day' => [
false,
Weekday::TUESDAY,
Weekday::TUESDAY,
],
'1 day later' => [
true,
Weekday::TUESDAY,
Weekday::MONDAY,
],
];
}
}
56 changes: 56 additions & 0 deletions tests/Weekday/IsBeforeOrEqualToTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

namespace DigitalCraftsman\DateTimePrecision\Weekday;

use DigitalCraftsman\DateTimePrecision\Weekday;
use PHPUnit\Framework\TestCase;

/** @coversDefaultClass \DigitalCraftsman\DateTimePrecision\Weekday */
final class IsBeforeOrEqualToTest extends TestCase
{
/**
* @test
*
* @dataProvider dataProvider
*
* @covers ::isBeforeOrEqualTo
*/
public function is_before_or_equal_to_works(
bool $expectedResult,
Weekday $weekday,
Weekday $comparator,
): void {
// -- Act & Assert
self::assertSame($expectedResult, $weekday->isBeforeOrEqualTo($comparator));
}

/**
* @return array<string, array{
* 0: boolean,
* 1: Weekday,
* 2: Weekday,
* }>
*/
public static function dataProvider(): array
{
return [
'1 day before' => [
true,
Weekday::MONDAY,
Weekday::TUESDAY,
],
'same day' => [
true,
Weekday::TUESDAY,
Weekday::TUESDAY,
],
'1 day later' => [
false,
Weekday::TUESDAY,
Weekday::MONDAY,
],
];
}
}
56 changes: 56 additions & 0 deletions tests/Weekday/IsNotAfterTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

namespace DigitalCraftsman\DateTimePrecision\Weekday;

use DigitalCraftsman\DateTimePrecision\Weekday;
use PHPUnit\Framework\TestCase;

/** @coversDefaultClass \DigitalCraftsman\DateTimePrecision\Weekday */
final class IsNotAfterTest extends TestCase
{
/**
* @test
*
* @dataProvider dataProvider
*
* @covers ::isNotAfter
*/
public function is_not_after_works(
bool $expectedResult,
Weekday $weekday,
Weekday $comparator,
): void {
// -- Act & Assert
self::assertSame($expectedResult, $weekday->isNotAfter($comparator));
}

/**
* @return array<string, array{
* 0: boolean,
* 1: Weekday,
* 2: Weekday,
* }>
*/
public static function dataProvider(): array
{
return [
'1 day before' => [
true,
Weekday::MONDAY,
Weekday::TUESDAY,
],
'same day' => [
true,
Weekday::TUESDAY,
Weekday::TUESDAY,
],
'1 day later' => [
false,
Weekday::TUESDAY,
Weekday::MONDAY,
],
];
}
}
56 changes: 56 additions & 0 deletions tests/Weekday/IsNotBeforeOrEqualToTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

declare(strict_types=1);

namespace DigitalCraftsman\DateTimePrecision\Weekday;

use DigitalCraftsman\DateTimePrecision\Weekday;
use PHPUnit\Framework\TestCase;

/** @coversDefaultClass \DigitalCraftsman\DateTimePrecision\Weekday */
final class IsNotBeforeOrEqualToTest extends TestCase
{
/**
* @test
*
* @dataProvider dataProvider
*
* @covers ::isNotBeforeOrEqualTo
*/
public function is_not_before_or_equal_to_works(
bool $expectedResult,
Weekday $weekday,
Weekday $comparator,
): void {
// -- Act & Assert
self::assertSame($expectedResult, $weekday->isNotBeforeOrEqualTo($comparator));
}

/**
* @return array<string, array{
* 0: boolean,
* 1: Weekday,
* 2: Weekday,
* }>
*/
public static function dataProvider(): array
{
return [
'1 day before' => [
false,
Weekday::MONDAY,
Weekday::TUESDAY,
],
'same day' => [
false,
Weekday::TUESDAY,
Weekday::TUESDAY,
],
'1 day later' => [
true,
Weekday::TUESDAY,
Weekday::MONDAY,
],
];
}
}

0 comments on commit dfde9bc

Please sign in to comment.