Fixing the Bug reading the ODS Sheetnames
incorrect sequence of arguments creating a Sheet in Reader/ODS/SheetIterator::current() Tests added.
This commit is contained in:
parent
1ce931a424
commit
b1b5c3f84b
@ -116,7 +116,7 @@ class SheetIterator implements IteratorInterface
|
|||||||
$escapedSheetName = $this->xmlReader->getAttribute(self::XML_ATTRIBUTE_TABLE_NAME);
|
$escapedSheetName = $this->xmlReader->getAttribute(self::XML_ATTRIBUTE_TABLE_NAME);
|
||||||
$sheetName = $this->escaper->unescape($escapedSheetName);
|
$sheetName = $this->escaper->unescape($escapedSheetName);
|
||||||
|
|
||||||
return new Sheet($this->xmlReader, $sheetName, $this->currentSheetIndex, $this->options);
|
return new Sheet($this->xmlReader, $this->currentSheetIndex, $sheetName, $this->options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
51
tests/Spout/Reader/ODS/SheetTest.php
Normal file
51
tests/Spout/Reader/ODS/SheetTest.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Box\Spout\Reader\ODS;
|
||||||
|
|
||||||
|
use Box\Spout\Common\Type;
|
||||||
|
use Box\Spout\Reader\ReaderFactory;
|
||||||
|
use Box\Spout\TestUsingResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class SheetTest
|
||||||
|
*
|
||||||
|
* @package Box\Spout\Reader\ODS
|
||||||
|
*/
|
||||||
|
class SheetTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
use TestUsingResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testNextSheetShouldReturnCorrectSheetInfos()
|
||||||
|
{
|
||||||
|
$sheets = $this->openFileAndReturnSheets('two_sheets_with_custom_names.ods');
|
||||||
|
|
||||||
|
$this->assertEquals('Sheet First', $sheets[0]->getName());
|
||||||
|
$this->assertEquals(0, $sheets[0]->getIndex());
|
||||||
|
|
||||||
|
$this->assertEquals('Sheet Last', $sheets[1]->getName());
|
||||||
|
$this->assertEquals(1, $sheets[1]->getIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $fileName
|
||||||
|
* @return Sheet[]
|
||||||
|
*/
|
||||||
|
private function openFileAndReturnSheets($fileName)
|
||||||
|
{
|
||||||
|
$resourcePath = $this->getResourcePath($fileName);
|
||||||
|
$reader = ReaderFactory::create(Type::ODS);
|
||||||
|
$reader->open($resourcePath);
|
||||||
|
|
||||||
|
$sheets = [];
|
||||||
|
foreach ($reader->getSheetIterator() as $sheet) {
|
||||||
|
$sheets[] = $sheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
$reader->close();
|
||||||
|
|
||||||
|
return $sheets;
|
||||||
|
}
|
||||||
|
}
|
BIN
tests/resources/ods/two_sheets_with_custom_names.ods
Normal file
BIN
tests/resources/ods/two_sheets_with_custom_names.ods
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user