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

DateRangeIteratorTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A dateRange_ShouldIterate() 0 10 2
A setUp() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Adlogix\EventSchedulerTest\DateRange;
6
7
use Adlogix\EventScheduler\DateRange\DateRange;
8
use Adlogix\EventScheduler\DateRange\DateRangeIterator;
9
use DateTimeImmutable;
10
use PHPUnit\Framework\TestCase;
11
12
class DateRangeIteratorTest extends TestCase
13
{
14
    protected $expectedDates = [];
15
16
    public function setUp()
17
    {
18
        $this->expectedDates = [
19
            new DateTimeImmutable('2015-03-01'),
20
            new DateTimeImmutable('2015-03-02'),
21
            new DateTimeImmutable('2015-03-03'),
22
            new DateTimeImmutable('2015-03-04'),
23
            new DateTimeImmutable('2015-03-05'),
24
        ];
25
    }
26
27
    /**
28
     * @test
29
     */
30
    public function dateRange_ShouldIterate()
31
    {
32
        $startDate = new DateTimeImmutable('2015-03-01');
33
        $endDate = new DateTimeImmutable('2015-03-05');
34
35
        $range = new DateRange($startDate, $endDate);
36
        $iterator = new DateRangeIterator($range);
37
38
        foreach ($iterator as $key => $date) {
39
            $this->assertEquals($this->expectedDates[$key], $date);
40
        }
41
    }
42
}
43