These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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
|
|||
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 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.