Adding more tests
This commit is contained in:
1 parent
2345a80784
commit
86a4c3790a
8 files changed
+140
-6
No files matched your search
@@ -154,7 +154,8 @@ class SharedStringsHelper
|
||||
|
||||
$readError = libxml_get_last_error();
|
||||
if ($readError !== false) {
|
||||
throw new IOException("The sharedStrings.xml file is invalid and cannot be read. [{$readError->message}]");
|
||||
$readErrorMessage = trim($readError->message);
|
||||
throw new IOException("The sharedStrings.xml file is invalid and cannot be read. [{$readErrorMessage}]");
|
||||
}
|
||||
|
||||
// reset the setting to display XML warnings/errors
|
||||
|
||||
@@ -131,12 +131,19 @@ class RowIterator implements IteratorInterface
|
||||
*
|
||||
* @return void
|
||||
* @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If a shared string was not found
|
||||
* @throws \Box\Spout\Common\Exception\IOException If unable to read the sheet data XML
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
$isInsideRowTag = false;
|
||||
$rowData = [];
|
||||
|
||||
// Use internal errors to avoid displaying lots of warning messages in case of invalid file
|
||||
// For instance on HHVM, XMLReader->open() won't fail when trying to read a unexisting file within a zip...
|
||||
// But the XMLReader->read() will fail!
|
||||
libxml_clear_errors();
|
||||
libxml_use_internal_errors(true);
|
||||
|
||||
while ($this->xmlReader->read()) {
|
||||
if ($this->xmlReader->nodeType == \XMLReader::ELEMENT && $this->xmlReader->name === self::XML_NODE_DIMENSION) {
|
||||
// Read dimensions of the sheet
|
||||
@@ -180,6 +187,12 @@ class RowIterator implements IteratorInterface
|
||||
}
|
||||
}
|
||||
|
||||
$readError = libxml_get_last_error();
|
||||
if ($readError !== false) {
|
||||
$readErrorMessage = trim($readError->message);
|
||||
throw new IOException("The {$this->sheetDataXMLFilePath} file cannot be read. [{$readErrorMessage}]");
|
||||
}
|
||||
|
||||
$this->rowDataBuffer = $rowData;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user