CallbackRecursiveIteratorTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testMainFunctionality() 0 30 3
1
<?php
2
3
namespace itertools;
4
5
use PHPUnit_Framework_TestCase;
6
7
8
class CallbackRecursiveIteratorTest extends PHPUnit_Framework_TestCase {
9
10
	/** @test */
11
	public function testMainFunctionality() {
12
		$root = array(
13
			'a',
14
			'b',
15
			array(
16
				'c1',
17
				array('c2kind'),
18
				'c3'
19
			),
20
			'd'
21
		);
22
		$it = new CallbackRecursiveIterator($root, function($e) {
23
			return is_array($e) ? $e : false;
24
		});
25
		$expected = array(
26
			'|-a',
27
			'|-b',
28
			'|-Array',
29
			'| |-c1',
30
			'| |-Array',
31
			'| | \-c2kind',
32
			'| \-c3',
33
			'\-d',
34
		);
35
		$i = 0;
36
		foreach(new \RecursiveTreeIterator($it) as $node) {
37
			$this->assertEquals($expected[$i], $node);
38
			$i += 1;
39
		}
40
	}
41
}
42
43