Prevent error when close() called while writer already closed (#402)

This commit is contained in:
Adrien Loison authored and GitHub committed 2017-03-28 15:07:48 +02:00
1 parent 742780613a
commit 4a65466b61
4 files changed
+56 -2

No files matched your search

+17
View File
@@ -61,6 +61,23 @@ class WriterTest extends \PHPUnit_Framework_TestCase
$writer->close();
}
/**
* @return void
*/
public function testCloseShouldNoopWhenWriterIsNotOpened()
{
$fileName = 'test_double_close_calls.csv';
$this->createGeneratedFolderIfNeeded($fileName);
$resourcePath = $this->getGeneratedResourcePath($fileName);
$writer = WriterFactory::create(Type::CSV);
$writer->close(); // This call should not cause any error
$writer->openToFile($fileName);
$writer->close();
$writer->close(); // This call should not cause any error
}
/**
* @return void
*/