HistoryIteratorTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testHistoryRetrieval() 0 22 1
A testNormalFunctionality() 0 5 1
1
<?php
2
3
namespace itertools;
4
5
use PHPUnit_Framework_TestCase;
6
7
8
class HistoryIteratorTest extends PHPUnit_Framework_TestCase
9
{
10
	/** @test */
11
	public function testHistoryRetrieval()
12
	{
13
		$it = new HistoryIterator(array(1, 2, 3, 4), 3);
14
15
		$it->rewind();
16
		$it->valid();
17
		$this->assertEquals(1, $it->current());
18
		$this->assertFalse($it->hasPrev());
19
20
		$it->next();
21
		$this->assertTrue($it->valid());
22
		$this->assertTrue($it->valid());
23
		$this->assertEquals(2, $it->current());
24
		$this->assertEquals(1, $it->prev(1));
25
		$this->assertTrue($it->hasPrev());
26
27
		$it->next();
28
		$this->assertTrue($it->valid());
29
		$this->assertEquals(3, $it->current());
30
		$this->assertEquals(2, $it->prev(1));
31
		$this->assertEquals(1, $it->prev(2));
32
	}
33
34
	/** @test */
35
	public function testNormalFunctionality()
36
	{
37
		$it = new HistoryIterator(array(1, 2, 3, 4));
38
		$this->assertEquals(4, count(iterator_to_array($it)));
39
	}
40
}
41
42