CountableIteratorReaderTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCount() 0 17 1
A testIteratorCount() 0 9 1
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