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

YearTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A constructor_GivenInvalidYearType_ShouldThrowTypeErrorException() 0 3 1
A includes_GivenDateAtDifferentYear_ShouldReturnFalse() 0 8 1
A includes_GivenDateAtSameYear_ShouldReturnTrue() 0 8 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\Year;
10
11
class YearTest extends TestCase
12
{
13
    /**
14
     * @test
15
     * @expectedException \TypeError
16
     */
17
    public function constructor_GivenInvalidYearType_ShouldThrowTypeErrorException()
18
    {
19
        new Year('invalid');
0 ignored issues
show
Bug introduced by
'invalid' of type string is incompatible with the type integer expected by parameter $year of Adlogix\EventScheduler\T...ion\Year::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

19
        new Year(/** @scrutinizer ignore-type */ 'invalid');
Loading history...
20
    }
21
22
    /**
23
     * @test
24
     */
25
    public function includes_GivenDateAtSameYear_ShouldReturnTrue()
26
    {
27
        $date = new DateTime('2015-04-10');
28
        $expr = new Year(2015);
29
30
        $isIncluded = $expr->includes($date);
31
32
        $this->assertThat($isIncluded, $this->isTrue());
33
    }
34
35
    /**
36
     * @test
37
     */
38
    public function includes_GivenDateAtDifferentYear_ShouldReturnFalse()
39
    {
40
        $date = new DateTime('2015-04-10');
41
        $expr = new Year(2016);
42
43
        $isIncluded = $expr->includes($date);
44
45
        $this->assertThat($isIncluded, $this->isFalse());
46
    }
47
}
48