-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ITST-20737: XLSX reader incorrectly handles empty <row> elements - Fix
- Refactor $row_open logic into $reader_points_at_new_row logic to simplify the code and reduce code duplication. - Add test EmptyRowsTest to cover the failing behavior. - Sidechange: Extend __construct() phpdoc with missing note regarding OutputColumnNames parameter.
- Loading branch information
1 parent
d36339d
commit 209c567
Showing
2 changed files
with
74 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Aspera\Spreadsheet\XLSX\Tests; | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use Exception; | ||
use PHPUnit\Framework\TestCase; | ||
use Aspera\Spreadsheet\XLSX\Reader; | ||
|
||
class EmptyRowsTest extends TestCase | ||
{ | ||
const TEST_FILE = __DIR__ . '/input_files/empty_rows_test.xlsx'; | ||
|
||
/** | ||
* Check if empty rows are detected and reported correctly. | ||
* Includes test of self-closing row elements caused by e.g. the usage of thick borders in adjacent cells. | ||
* | ||
* @throws Exception | ||
*/ | ||
public function testCellContent() | ||
{ | ||
$reader = new Reader(); | ||
$reader->open(self::TEST_FILE); | ||
$output_cells = array(); | ||
while ($row = $reader->next()) { | ||
$output_cells[] = $row[1]; // All values to check for are in the 2nd column. Ignore all other columns. | ||
} | ||
$reader->close(); | ||
|
||
self::assertSame( | ||
array('', 'row 2', '', '', 'row 5'), | ||
$output_cells, | ||
'The retrieved sheet content was not as expected.' | ||
); | ||
} | ||
} |