This commit is contained in:
madflow 2016-03-16 12:52:35 +01:00
parent 049fd990b9
commit 2b1160bb33
9 changed files with 103 additions and 0 deletions

View File

@ -343,6 +343,38 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expectedRows, $allRows); $this->assertEquals($expectedRows, $allRows);
} }
/**
* https://github.com/box/spout/issues/184
* @return void
*/
public function testReadShouldInludeRowsWithZerosOnly()
{
$allRows = $this->getAllRowsForFile('sheet_with_zeros_in_row.csv');
$expectedRows = [
['A', 'B', 'C'],
['1', '2', '3'],
['0', '0', '0']
];
$this->assertEquals($expectedRows, $allRows, 'There should be only 3 rows, because zeros (0) are valid values');
}
/**
* https://github.com/box/spout/issues/184
* @return void
*/
public function testReadShouldCreateOutputEmptyCellPreserved()
{
$allRows = $this->getAllRowsForFile('sheet_with_empty_cells.csv');
$expectedRows = [
['A', 'B', 'C'],
['0', '', ''],
['1', '1', '']
];
$this->assertEquals($expectedRows, $allRows, 'There should be 3 rows, with equal length');
}
/** /**
* @param string $fileName * @param string $fileName
* @param string|void $fieldDelimiter * @param string|void $fieldDelimiter

View File

@ -387,6 +387,38 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
$reader->open('php://memory'); $reader->open('php://memory');
} }
/**
* https://github.com/box/spout/issues/184
* @return void
*/
public function testReadShouldInludeRowsWithZerosOnly()
{
$allRows = $this->getAllRowsForFile('sheet_with_zeros_in_row.ods');
$expectedRows = [
['A', 'B', 'C'],
['1', '2', '3'],
['0', '0', '0']
];
$this->assertEquals($expectedRows, $allRows, 'There should be only 3 rows, because zeros (0) are valid values');
}
/**
* https://github.com/box/spout/issues/184
* @return void
*/
public function testReadShouldCreateOutputEmptyCellPreserved()
{
$allRows = $this->getAllRowsForFile('sheet_with_empty_cells.ods');
$expectedRows = [
['A', 'B', 'C'],
['0', '', ''],
['1', '1', '']
];
$this->assertEquals($expectedRows, $allRows, 'There should be 3 rows, with equal length');
}
/** /**
* @param string $fileName * @param string $fileName
* @return array All the read rows the given file * @return array All the read rows the given file

View File

@ -428,6 +428,39 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
$reader->open('php://memory'); $reader->open('php://memory');
} }
/**
* https://github.com/box/spout/issues/184
* @return void
*/
public function testReadShouldInludeRowsWithZerosOnly()
{
$allRows = $this->getAllRowsForFile('sheet_with_zeros_in_row.xlsx');
$expectedRows = [
['A', 'B', 'C'],
['1', '2', '3'],
['0', '0', '0']
];
$this->assertEquals($expectedRows, $allRows, 'There should be only 3 rows, because zeros (0) are valid values');
}
/**
* https://github.com/box/spout/issues/184
* @return void
*/
public function testReadShouldCreateOutputEmptyCellPreserved()
{
$allRows = $this->getAllRowsForFile('sheet_with_empty_cells.xlsx');
$expectedRows = [
['A', 'B', 'C'],
['0', '', ''],
['1', '1', '']
];
$this->assertEquals($expectedRows, $allRows, 'There should be 3 rows, with equal length');
}
/** /**
* @param string $fileName * @param string $fileName
* @return array All the read rows the given file * @return array All the read rows the given file

View File

@ -0,0 +1,3 @@
"A","B","C"
0,,
1,1,
1 A B C
2 0
3 1 1

View File

@ -0,0 +1,3 @@
"A","B","C"
1,2,3
0,0,0
1 A B C
2 1 2 3
3 0 0 0

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.