testInfiniteIteratorResult()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 15
rs 9.4285
cc 3
eloc 8
nc 3
nop 0
1
<?php
2
3
namespace Tests\Utils\Collections;
4
5
use Utils\Collections\InfiniteArrayCollection;
6
7
/**
8
 * InfiniteArrayCollection Test
9
 */
10
class InfiniteArrayCollectionTest extends \PHPUnit_Framework_TestCase
11
{
12
    /** @var array */
13
    protected $data = array(1, 2, 3);
14
15
    /** @var \Utils\Collections\InfiniteArrayCollection */
16
    protected $sut;
17
18
    /**
19
     * {@inheritDoc}
20
     */
21
    public function setUp()
22
    {
23
        $this->sut = new InfiniteArrayCollection($this->data);
24
    }
25
26
    /**
27
     * @test
28
     */
29
    public function testInfiniteIteratorResult()
30
    {
31
        $infiniteIterator = $this->sut->getInfiniteIterator();
32
        $this->assertInstanceOf('\InfiniteIterator', $infiniteIterator);
33
34
        $expectedValues = array_merge($this->data, $this->data, $this->data);
35
36
        foreach ($infiniteIterator as $value) {
37
            if (empty($expectedValues)) {
38
                break;
39
            }
40
41
            $this->assertEquals(array_shift($expectedValues), $value);
42
        }
43
    }
44
}
45