Fixing the Bug reading the ODS Sheetnames (#389)

incorrect sequence of arguments creating a Sheet in
Reader/ODS/SheetIterator::current()
Tests added.
This commit is contained in:
someson authored and Adrien Loison committed 2017-02-28 10:25:25 +11:00
1 parent 1ce931a424
commit 36d3596f83
3 files changed
+52 -1

No files matched your search

+1 -1
View File
@@ -116,7 +116,7 @@ class SheetIterator implements IteratorInterface
$escapedSheetName = $this->xmlReader->getAttribute(self::XML_ATTRIBUTE_TABLE_NAME);
$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
View 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;
}
}
Binary file not shown.