Skip to content

Commit

Permalink
Add encoding tests (work in progress)
Browse files Browse the repository at this point in the history
Add sample encoding file
  • Loading branch information
ppetrov committed Sep 15, 2017
1 parent b28c6bb commit 2f7dbc2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sample-data/cp1251.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"���","�������"
"������",31
26 changes: 26 additions & 0 deletions tests/CsvFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,30 @@ function test_throws_exception_when_using_non_number_characters_for_skip_to_colu
$csv = new CsvFile(__DIR__ . '/../sample-data/info.csv' );
$csv->skip_to_column('a');
}
/**
* @skip
*/
function test_non_utf8_encoded_file() {
$csv = new CsvFile(__DIR__ . '/../sample-data/cp1251.csv');
$csv->set_encoding('cp-1251');
$csv->use_first_row_as_header();
$csv->set_column_names([
'Име' => 'name',
'Възраст' => 'age',
]);
$this->assertEquals( [
[
'last_name' => 'Doe'
],
], $csv->to_array() );
}

function test_bad_mappings_are_providing_sane_error() {
$csv = new CsvFile(__DIR__ . '/../sample-data/cp1251.csv');
$csv->use_first_row_as_header();
$csv->set_column_names([
0 => 'name',
1 => 'age',
]);
}
}

0 comments on commit 2f7dbc2

Please sign in to comment.