Passed
Pull Request — master (#183)
by David
03:09
created

CachingIteratorTest::testCachingIterator2()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace TheCodingMachine\TDBM\Iterators;
4
5
use ArrayIterator;
6
use PHPUnit\Framework\TestCase;
7
use function iterator_to_array;
8
use function range;
9
10
class CachingIteratorTest extends TestCase
11
{
12
    public function testCachingIterator()
13
    {
14
        $it = new CachingIterator(new ArrayIterator(range(1,5)));
15
16
        $it[3];
17
        $this->assertArrayHasKey(3, $it);
18
        $this->assertCount(5, $it);
19
        $arr = iterator_to_array($it);
20
        $this->assertSame([1, 2, 3, 4, 5], $arr);
21
    }
22
23
    public function testCachingIterator2()
24
    {
25
        $it = new CachingIterator(new ArrayIterator(range(1,5)));
26
27
        $arr = iterator_to_array($it);
28
        $this->assertSame([1, 2, 3, 4, 5], $arr);
29
    }
30
}
31