Moved testAutoQuotes into existing test infrastructure

This commit is contained in:
Christian Bläul
2018-01-21 21:47:28 +01:00
parent 5a9a10aeed
commit 38944ba221
4 changed files with 20 additions and 26 deletions

View File

@@ -94,4 +94,24 @@ 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', "'"),
);
}
/**
* @dataProvider autoQuotesDataProvider
*
* @param string $file
* @param string $enclosure
*/
public function testAutoQuotes($file, $enclosure) {
$csv = new parseCSV();
$csv->auto($file, true, null, null, $enclosure);
$this->assertArrayHasKey('column1', $csv->data[0], 'Data parsed incorrectly with enclosure ' . $enclosure);
$this->assertEquals('value1', $csv->data[0]['column1'], 'Data parsed incorrectly with enclosure ' . $enclosure);
}
}

View File

@@ -1,26 +0,0 @@
<?php
class auto_Test 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', "'"),
);
}
/**
* @dataProvider autoQuotesDataProvider
*
* @param string $file
* @param string $enclosure
*/
public function testAutoQuotes($file, $enclosure)
{
$csv = new parseCSV();
$csv->auto($file, true, null, null, $enclosure);
$this->assertArrayHasKey('column1', $csv->data[0], 'Data parsed incorrectly with enclosure ' . $enclosure);
$this->assertEquals('value1', $csv->data[0]['column1'], 'Data parsed incorrectly with enclosure ' . $enclosure);
}
}

View File

@@ -1,3 +0,0 @@
"column1","column2"
"value1","value2"
"value3","value4"
1 column1 column2
2 value1 value2
3 value3 value4

View File

@@ -1,3 +0,0 @@
'column1','column2'
'value1','value2'
'value3','value4'
1 'column1' 'column2'
2 'value1' 'value2'
3 'value3' 'value4'