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

CachingIteratorTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 19
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCachingIterator2() 0 6 1
A testCachingIterator() 0 9 1
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