diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-11-20 20:39:43 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-11-20 20:39:43 -0500 |
commit | f119cbd6be467b3832a4543045980dd0f1936275 (patch) | |
tree | de15caae64fbf5318ce67000356af4e47b531ec6 /tests | |
parent | 4c3e519fa98de57ce9aa78f808b62f462aeaa690 (diff) |
Make CSV export compatible with PHP 5.3
Diffstat (limited to 'tests')
-rw-r--r-- | tests/units/Core/CsvTest.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/units/Core/CsvTest.php b/tests/units/Core/CsvTest.php index 71542c20..d34ccf76 100644 --- a/tests/units/Core/CsvTest.php +++ b/tests/units/Core/CsvTest.php @@ -19,4 +19,34 @@ class CsvTest extends Base $this->assertEquals(0, Csv::getBooleanValue('123')); $this->assertEquals(0, Csv::getBooleanValue('anything')); } + + public function testGetEnclosures() + { + $this->assertCount(3, Csv::getEnclosures()); + $this->assertCount(4, Csv::getDelimiters()); + } + + public function testReadWrite() + { + $filename = tempnam(sys_get_temp_dir(), 'UT'); + $rows = array( + array('Column A', 'Column B'), + array('value a', 'value b'), + ); + + $csv = new Csv; + $csv->write($filename, $rows); + $csv->setColumnMapping(array('A', 'B', 'C')); + $csv->read($filename, array($this, 'readRow')); + + unlink($filename); + + $this->expectOutputString('"Column A","Column B"'.PHP_EOL.'"value a","value b"'.PHP_EOL, $csv->output($rows)); + } + + public function readRow(array $row, $line) + { + $this->assertEquals(array('value a', 'value b', ''), $row); + $this->assertEquals(1, $line); + } } |