CountableIteratorReaderTest::testCount()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Ddeboer\DataImport\Tests\Reader;
4
5
use Ddeboer\DataImport\Reader\CountableIteratorReader;
6
7
/**
8
 * @author Márk Sági-Kazár <[email protected]>
9
 */
10
class CountableIteratorReaderTest extends \PHPUnit_Framework_TestCase
11
{
12
    public function testCount()
13
    {
14
        $iterator = new \ArrayIterator([
15
            [
16
                'id'       => 1,
17
                'username' => 'john.doe',
18
                'name'     => 'John Doe',
19
            ],
20
        ]);
21
22
        $reader = new CountableIteratorReader($iterator);
23
24
        // We need to rewind the iterator
25
        $reader->rewind();
26
27
        $this->assertEquals(1, $reader->count());
28
    }
29
30
    public function testIteratorCount()
31
    {
32
        $reader = new CountableIteratorReader(new CountableIterator);
33
34
        // We need to rewind the iterator
35
        $reader->rewind();
36
37
        $this->assertEquals(0, $reader->count());
38
    }
39
}
40
41
class CountableIterator extends \EmptyIterator
42
{
43
44
}
45