mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
PHPUnit: added test for UTF-8 and sep= row
Thanks to https://github.com/blaubaer! Some things in the CSV file originate from java-kata-1 by Gregor Noczinski
This commit is contained in:
5
tests/example_files/UTF-8_sep_row_but_no_BOM.csv
Normal file
5
tests/example_files/UTF-8_sep_row_but_no_BOM.csv
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
sep=;
|
||||||
|
title;isbn;publishedAt
|
||||||
|
Красивая кулинария;5454-5587-3210;21.05.2011
|
||||||
|
The Wine Connoisseurs;2547-8548-2541;12.12.2011
|
||||||
|
Weißwein;1313-4545-8875;23.02.2012
|
||||||
|
@@ -39,6 +39,11 @@ class parse_test extends PHPUnit_Framework_TestCase {
|
|||||||
$this->assertEquals($expected_data, $row);
|
$this->assertEquals($expected_data, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_sep_row_auto_detection_UTF8_no_BOM() {
|
||||||
|
$this->csv->auto(__DIR__ . '/../example_files/UTF-8_sep_row_but_no_BOM.csv');
|
||||||
|
$this->assertEquals($this->_get_magazines_data(), $this->csv->data);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_single_column() {
|
public function test_single_column() {
|
||||||
$this->csv->auto(__DIR__ . '/../example_files/single_column.csv');
|
$this->csv->auto(__DIR__ . '/../example_files/single_column.csv');
|
||||||
$expected = [
|
$expected = [
|
||||||
@@ -50,4 +55,24 @@ class parse_test extends PHPUnit_Framework_TestCase {
|
|||||||
|
|
||||||
$this->assertEquals($expected, $this->csv->data);
|
$this->assertEquals($expected, $this->csv->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function _get_magazines_data() {
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'title' => 'Красивая кулинария',
|
||||||
|
'isbn' => '5454-5587-3210',
|
||||||
|
'publishedAt' => '21.05.2011',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'title' => 'The Wine Connoisseurs',
|
||||||
|
'isbn' => '2547-8548-2541',
|
||||||
|
'publishedAt' => '12.12.2011',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'title' => 'Weißwein',
|
||||||
|
'isbn' => '1313-4545-8875',
|
||||||
|
'publishedAt' => '23.02.2012',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user