test improvements

This commit is contained in:
Susann Sgorzaly
2018-02-17 22:24:19 +01:00
parent 5babb55879
commit f8c68a6cd7
3 changed files with 26 additions and 26 deletions

View File

@@ -39,9 +39,26 @@ class ParseTest extends PHPUnit\Framework\TestCase {
$this->assertEquals($expected_data, $row);
}
public function test_sep_row_auto_detection_UTF8_no_BOM() {
$this->_autoparse_magazine_file(
__DIR__ . '/../example_files/UTF-8_sep_row_but_no_BOM.csv');
/**
* @depends test_parse
*
* @dataProvider autoDetectionProvider
*/
public function testSepRowAutoDetection($file) {
// This file (parse_test.php) is encoded in UTF-8, hence comparison will
// fail unless we to this:
$this->csv->output_encoding = 'UTF-8';
$this->csv->auto($file);
$this->assertEquals($this->_get_magazines_data(), $this->csv->data);
}
public function autoDetectionProvider(){
return [
'UTF8_no_BOM' => [__DIR__ . '/../example_files/UTF-8_sep_row_but_no_BOM.csv'],
'UTF8' => [__DIR__ . '/../example_files/UTF-8_with_BOM_and_sep_row.csv'],
'UTF16' => [__DIR__ . '/../example_files/UTF-16LE_with_BOM_and_sep_row.csv'],
];
}
public function testSingleColumnWithZeros() {
@@ -77,25 +94,6 @@ class ParseTest extends PHPUnit\Framework\TestCase {
], array_map('next', $actual_data));
}
public function test_sep_row_auto_detection_UTF8() {
$this->_autoparse_magazine_file(
__DIR__ . '/../example_files/UTF-8_with_BOM_and_sep_row.csv');
}
public function test_sep_row_auto_detection_UTF16() {
$this->_autoparse_magazine_file(
__DIR__ . '/../example_files/UTF-16LE_with_BOM_and_sep_row.csv');
}
protected function _autoparse_magazine_file($file) {
// This file (parse_test.php) is encoded in UTF-8, hence comparison will
// fail unless we to this:
$this->csv->output_encoding = 'UTF-8';
$this->csv->auto($file);
$this->assertEquals($this->_get_magazines_data(), $this->csv->data);
}
public function test_single_column() {
$this->csv->auto(__DIR__ . '/../example_files/single_column.csv');
$expected = [
@@ -151,13 +149,15 @@ class ParseTest extends PHPUnit\Framework\TestCase {
}
public function autoQuotesDataProvider() {
return array(
array('tests/methods/fixtures/auto-double-enclosure.csv', '"'),
array('tests/methods/fixtures/auto-single-enclosure.csv', "'"),
);
return [
'double-enclosure' => ['tests/methods/fixtures/auto-double-enclosure.csv', '"'],
'single-enclosure' => ['tests/methods/fixtures/auto-single-enclosure.csv', "'"],
];
}
/**
* @depends testSepRowAutoDetection
*
* @dataProvider autoQuotesDataProvider
*
* @param string $file