CallbackFilterIteratorTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testMainFunctionality() 0 6 1
A testInvalidCallback() 0 4 1
1
<?php
2
3
namespace itertools;
4
5
use EmptyIterator;
6
use ArrayIterator;
7
use PHPUnit_Framework_TestCase;
8
9
10
class CallbackFilterIteratorTest extends PHPUnit_Framework_TestCase
11
{
12
	/** @test */
13
	public function testMainFunctionality()
14
	{
15
		$it = new ArrayIterator(array(1, 2, 3, 4, 5));
16
		$it = new CallbackFilterIterator($it, function($v) { return $v != 2; });
17
		$this->assertEquals(array(1, 3, 4, 5), array_values(iterator_to_array($it)));
18
	}
19
20
	/**
21
	 * @test
22
	 * @expectedException \InvalidArgumentException
23
	 */
24
	public function testInvalidCallback()
25
	{
26
		new CallbackFilterIterator(new EmptyIterator(), null);
27
	}
28
}
29
30