SliceIteratorTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testSliceIterator() 0 9 1
A islice() 0 4 1
1
<?php
2
3
namespace itertools;
4
5
use ArrayIterator;
6
use PHPUnit_Framework_TestCase;
7
8
9
class SliceIteratorTest extends PHPUnit_Framework_TestCase
10
{
11
	/** @test */
12
	public function testSliceIterator()
13
	{
14
		$a = range(5, 20);
15
		$this->assertEquals(array_slice($a, 10), $this->islice($a, 10));
16
		$this->assertEquals(array_slice($a, 30), $this->islice($a, 30));
17
		$this->assertEquals(array_slice($a, 1, 5), $this->islice($a, 1, 5));
18
		$this->assertEquals(array_slice($a, 1, 200), $this->islice($a, 1, 200));
19
		$this->assertEquals(array_slice($a, 1, 200, true), $this->islice($a, 1, 200, true));
20
	}
21
22
	protected function islice($array, $offset, $length = INF, $preserve_keys = false)
23
	{
24
		return iterator_to_array(new SliceIterator($array, $offset, $length, $preserve_keys));
25
	}
26
}
27
28