Tests for #184
This commit is contained in:
parent
049fd990b9
commit
2b1160bb33
@ -343,6 +343,38 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
||||
$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|void $fieldDelimiter
|
||||
|
@ -387,6 +387,38 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
||||
$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
|
||||
* @return array All the read rows the given file
|
||||
|
@ -428,6 +428,39 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
||||
$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
|
||||
* @return array All the read rows the given file
|
||||
|
3
tests/resources/csv/sheet_with_empty_cells.csv
Normal file
3
tests/resources/csv/sheet_with_empty_cells.csv
Normal file
@ -0,0 +1,3 @@
|
||||
"A","B","C"
|
||||
0,,
|
||||
1,1,
|
|
3
tests/resources/csv/sheet_with_zeros_in_row.csv
Normal file
3
tests/resources/csv/sheet_with_zeros_in_row.csv
Normal file
@ -0,0 +1,3 @@
|
||||
"A","B","C"
|
||||
1,2,3
|
||||
0,0,0
|
|
BIN
tests/resources/ods/sheet_with_empty_cells.ods
Normal file
BIN
tests/resources/ods/sheet_with_empty_cells.ods
Normal file
Binary file not shown.
BIN
tests/resources/ods/sheet_with_zeros_in_row.ods
Normal file
BIN
tests/resources/ods/sheet_with_zeros_in_row.ods
Normal file
Binary file not shown.
BIN
tests/resources/xlsx/sheet_with_empty_cells.xlsx
Normal file
BIN
tests/resources/xlsx/sheet_with_empty_cells.xlsx
Normal file
Binary file not shown.
BIN
tests/resources/xlsx/sheet_with_zeros_in_row.xlsx
Normal file
BIN
tests/resources/xlsx/sheet_with_zeros_in_row.xlsx
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user