Merge 6572e713bf48de8e1e09670143584e4d60e2b3a7 into 5d4166196ad5bcde89f7316d273ef13eff144666

This commit is contained in:
Alexey Rehov 2017-06-04 16:57:31 +00:00 committed by GitHub
commit 1fbf440253
2 changed files with 14 additions and 1 deletions

View File

@ -125,7 +125,7 @@ class Writer extends AbstractMultiSheetsWriter
*/
protected function closeWriter()
{
if ($this->book) {
if ($this->book && $this->isWriterOpened) {
$this->book->close($this->filePointer);
}
}

View File

@ -507,6 +507,19 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', $finfo->file($resourcePath));
}
/**
* @return void
*/
public function testCloseIsNotAppliedWhenWriterIsNotOpened()
{
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
$writer = WriterFactory::create(Type::XLSX);
$writer->openToFile('test_close.xlsx');
$writer->addRow(['foo']);
$writer->close();
$writer->close();
}
/**
* @param array $allRows
* @param string $fileName