Passed
Branch master (73f5a3)
by Toni
02:45
created

RangeEachYearTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A includes_GivenDatesFromDataProvider_ShouldMatchExpectedValue() 0 13 1
A getDataProvider() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Adlogix\EventSchedulerTest\TemporalExpression;
6
7
use DateTime;
8
use PHPUnit\Framework\TestCase;
9
use Adlogix\EventScheduler\TemporalExpression\RangeEachYear;
10
use Adlogix\EventScheduler\ValueObject\Month;
11
use Adlogix\EventScheduler\ValueObject\MonthDay;
12
13
/**
14
 * @author Toni Van de Voorde <[email protected]>
15
 */
16
final class RangeEachYearTest extends TestCase
17
{
18
    public function getDataProvider()
19
    {
20
        return [
21
            [Month::january(), Month::march(), null, null, new DateTime('2015-02-05'), true],
22
            [Month::january(), Month::march(), new MonthDay(10), new MonthDay(20), new DateTime('2015-01-05'), false],
23
            [Month::january(), Month::march(), new MonthDay(10), new MonthDay(20), new DateTime('2015-02-05'), true],
24
            [Month::january(), Month::march(), new MonthDay(10), new MonthDay(20), new DateTime('2015-03-05'), true],
25
            [Month::january(), Month::march(), new MonthDay(10), new MonthDay(20), new DateTime('2015-03-25'), false],
26
            [Month::december(), Month::april(), new MonthDay(20), new MonthDay(10), new DateTime('2015-03-15'), true],
27
        ];
28
    }
29
30
    /**
31
     * @test
32
     * @dataProvider getDataProvider
33
     * @param Month              $startMonth
34
     * @param Month              $endMonth
35
     * @param MonthDay           $startDay
36
     * @param MonthDay           $endDay
37
     * @param \DateTimeInterface $date
38
     * @param bool               $expected
39
     */
40
    public function includes_GivenDatesFromDataProvider_ShouldMatchExpectedValue(
41
        Month $startMonth,
42
        Month $endMonth,
43
        MonthDay $startDay = null,
44
        MonthDay $endDay = null,
45
        \DateTimeInterface $date,
46
        bool $expected
47
    ) {
48
        $expr = new RangeEachYear($startMonth, $endMonth, $startDay, $endDay);
49
50
        $isIncluded = $expr->includes($date);
51
52
        $this->assertSame($expected, $isIncluded);
53
    }
54
}
55