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

CsvTableReaderTest::testCsvReading()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
rs 9.4285
cc 2
eloc 10
nc 2
nop 0
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