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

SemesterTest::getUnsuccessfulDataProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
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\Semester;
10
11
/**
12
 * @author Toni Van de Voorde <[email protected]>
13
 */
14
final class SemesterTest extends TestCase
15
{
16
    /**
17
     * @return array
18
     */
19
    public function getSuccessfulDataProvider()
20
    {
21
        $first = Semester::first();
22
        $second = Semester::second();
23
24
        return [
25
            [new DateTime('2015-01-01'), $first],
26
            [new DateTime('2015-04-10'), $first],
27
            [new DateTime('2015-06-30'), $first],
28
            [new DateTime('2015-07-01'), $second],
29
            [new DateTime('2015-10-15'), $second],
30
            [new DateTime('2015-12-31'), $second],
31
        ];
32
    }
33
34
    /**
35
     * @test
36
     * @dataProvider getSuccessfulDataProvider
37
     * @param DateTime $date
38
     * @param          $semester
39
     */
40
    public function includes_GivenDateAtSameSemester_ShouldReturnTrue(DateTime $date, $semester)
41
    {
42
        $this->includesDate($date, $semester, true);
43
    }
44
45
    /**
46
     * @return array
47
     */
48
    public function getUnsuccessfulDataProvider()
49
    {
50
        $first = Semester::first();
51
        $second = Semester::second();
52
53
        return [
54
            [new DateTime('2015-01-01'), $second],
55
            [new DateTime('2015-04-10'), $second],
56
            [new DateTime('2015-06-30'), $second],
57
            [new DateTime('2015-07-01'), $first],
58
            [new DateTime('2015-10-15'), $first],
59
            [new DateTime('2015-12-31'), $first],
60
        ];
61
    }
62
63
    /**
64
     * @test
65
     * @dataProvider getUnsuccessfulDataProvider
66
     * @param DateTime $date
67
     * @param Semester $semester
68
     */
69
    public function includes_GivenDateAtDifferentSemester_ShouldReturnFalse(DateTime $date, Semester $semester)
70
    {
71
        $this->includesDate($date, $semester, false);
72
    }
73
74
    /**
75
     * @param DateTime $date
76
     * @param Semester $semester
77
     * @param bool     $expected
78
     */
79
    private function includesDate(DateTime $date, Semester $semester, bool $expected)
80
    {
81
        $output = $semester->includes($date);
82
83
        $this->assertSame($expected, $output);
84
    }
85
}
86