mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
Merge pull request #133 from parsecsv/fixing-132-output-with-fields
Bug fix: calling ->output() with $fields parameter set
This commit is contained in:
@@ -64,7 +64,6 @@ class DataRowCountTest extends TestCase {
|
||||
$this->assertEquals(3, $this->csv->getTotalDataRowCount());
|
||||
}
|
||||
|
||||
|
||||
public function testGetTotalRowCountSingleEnclosure() {
|
||||
$this->csv->heading = false;
|
||||
$this->csv->enclosure = "'";
|
||||
@@ -73,4 +72,11 @@ class DataRowCountTest extends TestCase {
|
||||
$this->assertEquals(3, $this->csv->getTotalDataRowCount());
|
||||
}
|
||||
|
||||
public function testGetTotalRowCountSingleRow() {
|
||||
$this->csv->heading = false;
|
||||
$this->csv->enclosure = "'";
|
||||
$sInput = "86545235689";
|
||||
$this->csv->load_data($sInput);
|
||||
$this->assertEquals(1, $this->csv->getTotalDataRowCount());
|
||||
}
|
||||
}
|
||||
|
||||
21
tests/methods/OutputTest.php
Normal file
21
tests/methods/OutputTest.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace ParseCsv\tests\methods;
|
||||
|
||||
use ParseCsv\Csv;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class OutputTest extends TestCase {
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess because download.php uses header()
|
||||
*/
|
||||
public function testOutputWithFourParameters() {
|
||||
$csv = new Csv();
|
||||
$data = [0 => ['a', 'b', 'c'], 1 => ['d', 'e', 'f']];
|
||||
$fields = ['col1', 'col2', 'col3'];
|
||||
$output = $csv->output('test.csv', $data, $fields, ',');
|
||||
$expected = "col1,col2,col3\ra,b,c\rd,e,f\r";
|
||||
self::assertEquals($expected, $output);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user