FixedLengthFormattedStringIteratorTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testSimpleFunctionality() 0 15 1
A testComposingIterator() 0 3 1
A testFileCsvIteratorWithInvalidArguments() 0 4 1
1
<?php
2
3
namespace itertools;
4
5
use PHPUnit_Framework_TestCase;
6
7
8
class FixedLengthFormattedStringIteratorTest extends PHPUnit_Framework_TestCase
9
{
10
	/** @test */
11
	public function testSimpleFunctionality()
12
	{
13
		$input = array(
14
			'jos            , 1  , m',
15
			'piet           , 120, m',
16
			'tutu le wallon , 50 , f',
17
		);
18
		$template = 
19
			'<name         >  age, g';
20
		$names = array('g' => 'gender');
21
		$result = iterator_to_array(FixedLengthFormattedStringIterator::newFromTemplate($input, $template, $names, array('trim' => ' ')));
22
		$this->assertEquals('jos', $result[0]['name']);
23
		$this->assertEquals('120', $result[1]['age']);
24
		$this->assertEquals('m', $result[1]['gender']);
25
	}
26
27
	/** @test */
28
	public function testComposingIterator()
29
	{
30
	}
31
32
	/**
33
	 * @test
34
	 * @expectedException InvalidArgumentException
35
	 */
36
	public function testFileCsvIteratorWithInvalidArguments()
37
	{
38
		new FixedLengthFormattedStringIterator(array(), array(), array('invalid' => 'option'));
39
	}
40
}
41
42