HistoryIteratorTest::testHistoryRetrieval()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
cc 1
nc 1
nop 0
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