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

UnionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A includes_GivenDatesFromDataProvider_ShouldMatchExpectedValue() 0 17 1
A getDataProvider() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Adlogix\EventSchedulerTest\TemporalExpression\Collection;
6
7
use DateTime;
8
use PHPUnit\Framework\TestCase;
9
use Adlogix\EventScheduler\TemporalExpression\Collection\Union;
10
use Adlogix\EventScheduler\TemporalExpression\TemporalExpressionInterface;
11
12
class UnionTest extends TestCase
13
{
14
    public function getDataProvider()
15
    {
16
        return [
17
            [true, true, true],
18
            [true, false, true],
19
            [false, true, true],
20
            [false, false, false],
21
        ];
22
    }
23
24
    /**
25
     * @test
26
     * @dataProvider getDataProvider
27
     */
28
    public function includes_GivenDatesFromDataProvider_ShouldMatchExpectedValue($first, $second, $expected)
29
    {
30
        $anyDate = new DateTime();
31
32
        $expr = new Union();
33
34
        $firstExpr = $this->prophesize(TemporalExpressionInterface::class);
35
        $firstExpr->includes($anyDate)->willReturn($first);
36
        $expr->addElement($firstExpr->reveal());
37
38
        $secondExpr = $this->prophesize(TemporalExpressionInterface::class);
39
        $secondExpr->includes($anyDate)->willReturn($second);
40
        $expr->addElement($secondExpr->reveal());
41
42
        $isIncluded = $expr->includes($anyDate);
43
44
        $this->assertSame($expected, $isIncluded);
45
    }
46
}
47