Throw if XLSX Writer configured after being opened
This commit is contained in:
1 parent
b4ace972e7
commit
1812b4f996
3 files changed
+88
No files matched your search
@@ -46,6 +46,51 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
||||
$writer->addRows([['xlsx--11', 'xlsx--12']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Box\Spout\Writer\Exception\WriterAlreadyOpenedException
|
||||
*/
|
||||
public function testSetTempFolderShouldThrowExceptionIfCalledAfterOpeningWriter()
|
||||
{
|
||||
$fileName = 'file_that_wont_be_written.xlsx';
|
||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterFactory::create(Type::XLSX);
|
||||
$writer->openToFile($filePath);
|
||||
|
||||
$writer->setTempFolder('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Box\Spout\Writer\Exception\WriterAlreadyOpenedException
|
||||
*/
|
||||
public function testSetShouldUseInlineStringsShouldThrowExceptionIfCalledAfterOpeningWriter()
|
||||
{
|
||||
$fileName = 'file_that_wont_be_written.xlsx';
|
||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterFactory::create(Type::XLSX);
|
||||
$writer->openToFile($filePath);
|
||||
|
||||
$writer->setShouldUseInlineStrings(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Box\Spout\Writer\Exception\WriterAlreadyOpenedException
|
||||
*/
|
||||
public function testsetShouldCreateNewSheetsAutomaticallyShouldThrowExceptionIfCalledAfterOpeningWriter()
|
||||
{
|
||||
$fileName = 'file_that_wont_be_written.xlsx';
|
||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||
|
||||
/** @var \Box\Spout\Writer\XLSX\Writer $writer */
|
||||
$writer = WriterFactory::create(Type::XLSX);
|
||||
$writer->openToFile($filePath);
|
||||
|
||||
$writer->setShouldCreateNewSheetsAutomatically(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Box\Spout\Common\Exception\InvalidArgumentException
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user