MapIteratorTest::testInvalidArgument()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
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 ArrayIterator;
7
use PHPUnit_Framework_TestCase;
8
9
10
class MapIteratorTest extends PHPUnit_Framework_TestCase
11
{
12
	/** @test */
13
	public function testMapIterator()
14
	{
15
		$square = function($n) { return $n * $n; };
16
		$this->assertEquals(array_map($square, array(1, 2, 3)), $this->imap(array(1, 2, 3), $square));
17
	}
18
19
	/**
20
	 * @test
21
	 * @expectedException \InvalidArgumentException
22
	 */
23
	public function testInvalidArgument()
24
	{
25
		new MapIterator(new EmptyIterator(), 1);
26
	}
27
28
	protected function imap($array, $callable)
29
	{
30
		return iterator_to_array(new MapIterator($array, $callable));
31
	}
32
}
33
34