Passed
Pull Request — master (#179)
by David
02:35
created

EmptyInnerResultIteratorTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 18
c 1
b 0
f 0
dl 0
loc 42
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testOffsetSet() 0 5 1
A testOffsetGet() 0 5 1
A testCount() 0 4 1
A testIterate() 0 7 2
A testOffsetExists() 0 4 1
A testOffsetUnset() 0 5 1
1
<?php
2
3
namespace TheCodingMachine\TDBM;
4
5
use PHPUnit\Framework\TestCase;
6
7
class EmptyInnerResultIteratorTest extends TestCase
8
{
9
    public function testOffsetUnset()
10
    {
11
        $iterator = new EmptyInnerResultIterator();
12
        $this->expectException(TDBMInvalidOperationException::class);
13
        unset($iterator[42]);
14
    }
15
16
    public function testCount()
17
    {
18
        $iterator = new EmptyInnerResultIterator();
19
        $this->assertCount(0, $iterator);
20
    }
21
22
    public function testOffsetExists()
23
    {
24
        $iterator = new EmptyInnerResultIterator();
25
        $this->assertFalse(isset($iterator[0]));
26
    }
27
28
    public function testOffsetSet()
29
    {
30
        $iterator = new EmptyInnerResultIterator();
31
        $this->expectException(TDBMInvalidOperationException::class);
32
        $iterator[42] = 'foo';
33
    }
34
35
    public function testIterate()
36
    {
37
        $iterator = new EmptyInnerResultIterator();
38
        foreach ($iterator as $elem) {
39
            $this->fail('Iterator should be empty');
40
        }
41
        $this->assertTrue(true);
42
    }
43
44
    public function testOffsetGet()
45
    {
46
        $iterator = new EmptyInnerResultIterator();
47
        $this->expectException(TDBMInvalidOffsetException::class);
48
        $iterator[42];
49
    }
50
}
51