Adding open_file_in_zip() helper function to XMLReader (#238)

This commit is contained in:
Adrien Loison committed 2016-05-29 23:22:57 -07:00
1 parent 03866a6604
commit 251c0bebc1
8 files changed
+64 -111

No files matched your search

@@ -293,13 +293,16 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
private function getXmlSectionFromStylesXmlFile($fileName, $section)
{
$resourcePath = $this->getGeneratedResourcePath($fileName);
$pathToStylesXmlFile = $resourcePath . '#xl/styles.xml';
$xmlReader = new XMLReader();
$xmlReader->open('zip://' . $pathToStylesXmlFile);
$xmlReader->openFileInZip($resourcePath, 'xl/styles.xml');
$xmlReader->readUntilNodeFound($section);
return $xmlReader->expand();
$xmlSection = $xmlReader->expand();
$xmlReader->close();
return $xmlSection;
}
/**
@@ -311,17 +314,18 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
$cellElements = [];
$resourcePath = $this->getGeneratedResourcePath($fileName);
$pathToStylesXmlFile = $resourcePath . '#xl/worksheets/sheet1.xml';
$xmlReader = new \XMLReader();
$xmlReader->open('zip://' . $pathToStylesXmlFile);
$xmlReader = new XMLReader();
$xmlReader->openFileInZip($resourcePath, 'xl/worksheets/sheet1.xml');
while ($xmlReader->read()) {
if ($xmlReader->nodeType === \XMLReader::ELEMENT && $xmlReader->name === 'c') {
if ($xmlReader->isPositionedOnStartingNode('c')) {
$cellElements[] = $xmlReader->expand();
}
}
$xmlReader->close();
return $cellElements;
}