testFilterWithNonStrictComparisation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace itertools;
4
5
use EmptyIterator;
6
use PHPUnit_Framework_TestCase;
7
use ArrayIterator;
8
9
10
class UniqueIteratorTest extends PHPUnit_Framework_TestCase
11
{
12
	/** @test */
13
	public function testFilterWithStrictComparisation()
14
	{
15
		$it = new ArrayIterator(array('1', 1, 1, 1, '1', '1'));
16
17
		$data = iterator_to_array(new UniqueIterator($it, array('compareType' => UniqueIterator::COMPARE_STRICT)));
18
		$this->assertEquals(array('1', 1, '1'), array_values($data));
19
	}
20
21
	/** @test */
22
	public function testFilterWithNonStrictComparisation()
23
	{
24
		$it = new ArrayIterator(array('1', 1, 1, 1, '1', 1, 2, '2', 2, '2'));
25
26
		$data = iterator_to_array(new UniqueIterator($it, array('compareType' => UniqueIterator::COMPARE_NONSTRICT)));
27
		$this->assertEquals(array('1', 2), array_values($data));
28
	}
29
30
	/**
31
	 * @test
32
	 * @expectedException \InvalidArgumentException
33
	 */
34
	public function testShouldWarningIfInvalidOptionsAreSpecified()
35
	{
36
		new UniqueIterator(new EmptyIterator(), array('unkownOptions' => 'value'));
37
	}
38
}
39
40