Completed
Pull Request — master (#42)
by Sam
02:33
created

CsvTableReaderTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCsvReading() 0 19 2
1
<?php
2
3
use SilverStripe\SsPak\DataExtractor\CsvTableReader;
4
5
class CsvTableReaderTest extends PHPUnit_Framework_TestCase
6
{
7
	function testCsvReading() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
8
9
		$csv = new CsvTableReader(__DIR__ . '/fixture/input.csv');
10
		$this->assertEquals(['Col1', 'Col2', 'Col3'], $csv->getColumns());
11
12
		$extractedData = [];
13
		foreach($csv as $record) {
14
			$extractedData[] = $record;
15
		}
16
17
		$this->assertEquals(
18
			[
19
				[ 'Col1' => 'One', 'Col2' => 2, 'Col3' => 'Three' ],
20
				[ 'Col1' => 'Hello, Sam', 'Col2' => 5, 'Col3' => "Nice to meet you\nWhat is your name?" ]
21
			],
22
			$extractedData
23
		);
24
25
	}
26
}
27