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

DifferenceTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDataProvider() 0 7 1
A includes_GivenDatesFromDataProvider_ShouldMatchExpectedValue() 0 18 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\TemporalExpressionInterface;
10
use Adlogix\EventScheduler\TemporalExpression\Difference;
11
12
class DifferenceTest extends TestCase
13
{
14
    public function getDataProvider()
15
    {
16
        return [
17
            [true, true, false],
18
            [true, false, true],
19
            [false, true, false],
20
            [false, false, false],
21
        ];
22
    }
23
24
    /**
25
     * @test
26
     * @dataProvider getDataProvider
27
     */
28
    public function includes_GivenDatesFromDataProvider_ShouldMatchExpectedValue($included, $excluded, $expected)
29
    {
30
        $anyDate = new DateTime();
31
32
        $includedExpr = $this->prophesize(TemporalExpressionInterface::class);
33
        $includedExpr->includes($anyDate)->willReturn($included);
34
35
        $excludedExpr = $this->prophesize(TemporalExpressionInterface::class);
36
        $excludedExpr->includes($anyDate)->willReturn($excluded);
37
38
        $expr = new Difference(
39
            $includedExpr->reveal(),
40
            $excludedExpr->reveal()
41
        );
42
43
        $isIncluded = $expr->includes($anyDate);
44
45
        $this->assertSame($expected, $isIncluded);
46
    }
47
}
48