Remove @expectedException annotation
This commit is contained in:
parent
7274226b75
commit
3851e05f83
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Box\Spout\Common\Helper;
|
namespace Box\Spout\Common\Helper;
|
||||||
|
|
||||||
|
use Box\Spout\Common\Exception\EncodingConversionException;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,13 +58,14 @@ class EncodingHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider dataProviderForIconvOrMbstringUsage
|
* @dataProvider dataProviderForIconvOrMbstringUsage
|
||||||
* @expectedException \Box\Spout\Common\Exception\EncodingConversionException
|
|
||||||
*
|
*
|
||||||
* @param bool $shouldUseIconv
|
* @param bool $shouldUseIconv
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAttemptConversionToUTF8ShouldThrowIfConversionFailed($shouldUseIconv)
|
public function testAttemptConversionToUTF8ShouldThrowIfConversionFailed($shouldUseIconv)
|
||||||
{
|
{
|
||||||
|
$this->expectException(EncodingConversionException::class);
|
||||||
|
|
||||||
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
||||||
->setMethods(['iconv', 'mb_convert_encoding'])
|
->setMethods(['iconv', 'mb_convert_encoding'])
|
||||||
->getMock();
|
->getMock();
|
||||||
@ -82,12 +84,12 @@ class EncodingHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\EncodingConversionException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAttemptConversionToUTF8ShouldThrowIfConversionNotSupported()
|
public function testAttemptConversionToUTF8ShouldThrowIfConversionNotSupported()
|
||||||
{
|
{
|
||||||
|
$this->expectException(EncodingConversionException::class);
|
||||||
|
|
||||||
/** @var EncodingHelper $encodingHelperStub */
|
/** @var EncodingHelper $encodingHelperStub */
|
||||||
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
@ -139,13 +141,14 @@ class EncodingHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider dataProviderForIconvOrMbstringUsage
|
* @dataProvider dataProviderForIconvOrMbstringUsage
|
||||||
* @expectedException \Box\Spout\Common\Exception\EncodingConversionException
|
|
||||||
*
|
*
|
||||||
* @param bool $shouldUseIconv
|
* @param bool $shouldUseIconv
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAttemptConversionFromUTF8ShouldThrowIfConversionFailed($shouldUseIconv)
|
public function testAttemptConversionFromUTF8ShouldThrowIfConversionFailed($shouldUseIconv)
|
||||||
{
|
{
|
||||||
|
$this->expectException(EncodingConversionException::class);
|
||||||
|
|
||||||
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
||||||
->setMethods(['iconv', 'mb_convert_encoding'])
|
->setMethods(['iconv', 'mb_convert_encoding'])
|
||||||
->getMock();
|
->getMock();
|
||||||
@ -164,12 +167,12 @@ class EncodingHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\EncodingConversionException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAttemptConversionFromUTF8ShouldThrowIfConversionNotSupported()
|
public function testAttemptConversionFromUTF8ShouldThrowIfConversionNotSupported()
|
||||||
{
|
{
|
||||||
|
$this->expectException(EncodingConversionException::class);
|
||||||
|
|
||||||
/** @var EncodingHelper $encodingHelperStub */
|
/** @var EncodingHelper $encodingHelperStub */
|
||||||
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
$encodingHelperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\EncodingHelper')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
namespace Box\Spout\Common\Helper;
|
namespace Box\Spout\Common\Helper;
|
||||||
|
|
||||||
|
use Box\Spout\Common\Exception\IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class FileSystemHelperTest
|
* Class FileSystemHelperTest
|
||||||
*/
|
*/
|
||||||
class FileSystemHelperTest extends \PHPUnit_Framework_TestCase
|
class FileSystemHelperTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/** @var \Box\Spout\Writer\Helper\XLSX\FileSystemHelper */
|
/** @var \Box\Spout\Writer\XLSX\Helper\FileSystemHelper */
|
||||||
protected $fileSystemHelper;
|
protected $fileSystemHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,38 +22,42 @@ class FileSystemHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testCreateFolderShouldThrowExceptionIfOutsideOfBaseFolder()
|
public function testCreateFolderShouldThrowExceptionIfOutsideOfBaseFolder()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
$this->fileSystemHelper->createFolder('/tmp/folder_outside_base_folder', 'folder_name');
|
$this->fileSystemHelper->createFolder('/tmp/folder_outside_base_folder', 'folder_name');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testCreateFileWithContentsShouldThrowExceptionIfOutsideOfBaseFolder()
|
public function testCreateFileWithContentsShouldThrowExceptionIfOutsideOfBaseFolder()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
$this->fileSystemHelper->createFileWithContents('/tmp/folder_outside_base_folder', 'file_name', 'contents');
|
$this->fileSystemHelper->createFileWithContents('/tmp/folder_outside_base_folder', 'file_name', 'contents');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testDeleteFileShouldThrowExceptionIfOutsideOfBaseFolder()
|
public function testDeleteFileShouldThrowExceptionIfOutsideOfBaseFolder()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
$this->fileSystemHelper->deleteFile('/tmp/folder_outside_base_folder/file_name');
|
$this->fileSystemHelper->deleteFile('/tmp/folder_outside_base_folder/file_name');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testDeleteFolderRecursivelyShouldThrowExceptionIfOutsideOfBaseFolder()
|
public function testDeleteFolderRecursivelyShouldThrowExceptionIfOutsideOfBaseFolder()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
$this->fileSystemHelper->deleteFolderRecursively('/tmp/folder_outside_base_folder');
|
$this->fileSystemHelper->deleteFolderRecursively('/tmp/folder_outside_base_folder');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
namespace Box\Spout\Reader\CSV;
|
namespace Box\Spout\Reader\CSV;
|
||||||
|
|
||||||
use Box\Spout\Common\Creator\HelperFactory;
|
use Box\Spout\Common\Creator\HelperFactory;
|
||||||
|
use Box\Spout\Common\Exception\IOException;
|
||||||
use Box\Spout\Common\Helper\EncodingHelper;
|
use Box\Spout\Common\Helper\EncodingHelper;
|
||||||
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
|
||||||
use Box\Spout\Reader\CSV\Creator\EntityFactory;
|
use Box\Spout\Reader\CSV\Creator\EntityFactory;
|
||||||
use Box\Spout\Reader\CSV\Manager\OptionsManager;
|
use Box\Spout\Reader\CSV\Manager\OptionsManager;
|
||||||
|
use Box\Spout\Reader\Exception\ReaderNotOpenedException;
|
||||||
use Box\Spout\Reader\ReaderInterface;
|
use Box\Spout\Reader\ReaderInterface;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
|
|
||||||
@ -18,32 +20,32 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
use TestUsingResource;
|
use TestUsingResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testOpenShouldThrowExceptionIfFileDoesNotExist()
|
public function testOpenShouldThrowExceptionIfFileDoesNotExist()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
$this->createCSVReader()->open('/path/to/fake/file.csv');
|
$this->createCSVReader()->open('/path/to/fake/file.csv');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Reader\Exception\ReaderNotOpenedException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testOpenShouldThrowExceptionIfTryingToReadBeforeOpeningReader()
|
public function testOpenShouldThrowExceptionIfTryingToReadBeforeOpeningReader()
|
||||||
{
|
{
|
||||||
|
$this->expectException(ReaderNotOpenedException::class);
|
||||||
|
|
||||||
$this->createCSVReader()->getSheetIterator();
|
$this->createCSVReader()->getSheetIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testOpenShouldThrowExceptionIfFileNotReadable()
|
public function testOpenShouldThrowExceptionIfFileNotReadable()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
/** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper|\PHPUnit_Framework_MockObject_MockObject $helperStub */
|
/** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper|\PHPUnit_Framework_MockObject_MockObject $helperStub */
|
||||||
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
||||||
->setMethods(['is_readable'])
|
->setMethods(['is_readable'])
|
||||||
@ -57,12 +59,12 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testOpenShouldThrowExceptionIfCannotOpenFile()
|
public function testOpenShouldThrowExceptionIfCannotOpenFile()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
/** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper|\PHPUnit_Framework_MockObject_MockObject $helperStub */
|
/** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper|\PHPUnit_Framework_MockObject_MockObject $helperStub */
|
||||||
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
|
||||||
->setMethods(['fopen'])
|
->setMethods(['fopen'])
|
||||||
@ -449,12 +451,12 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testReadWithUnsupportedCustomStreamWrapper()
|
public function testReadWithUnsupportedCustomStreamWrapper()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
/** @var \Box\Spout\Reader\CSV\Reader $reader */
|
/** @var \Box\Spout\Reader\CSV\Reader $reader */
|
||||||
$reader = $this->createCSVReader();
|
$reader = $this->createCSVReader();
|
||||||
$reader->open('unsupported://foobar');
|
$reader->open('unsupported://foobar');
|
||||||
|
@ -4,6 +4,7 @@ namespace Box\Spout\Reader\ODS;
|
|||||||
|
|
||||||
use Box\Spout\Common\Exception\IOException;
|
use Box\Spout\Common\Exception\IOException;
|
||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
|
use Box\Spout\Reader\Exception\IteratorNotRewindableException;
|
||||||
use Box\Spout\Reader\ReaderFactory;
|
use Box\Spout\Reader\ReaderFactory;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
|
|
||||||
@ -27,13 +28,14 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider dataProviderForTestReadShouldThrowException
|
* @dataProvider dataProviderForTestReadShouldThrowException
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
|
||||||
*
|
*
|
||||||
* @param string $filePath
|
* @param string $filePath
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testReadShouldThrowException($filePath)
|
public function testReadShouldThrowException($filePath)
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
// using @ to prevent warnings/errors from being displayed
|
// using @ to prevent warnings/errors from being displayed
|
||||||
@$this->getAllRowsForFile($filePath);
|
@$this->getAllRowsForFile($filePath);
|
||||||
}
|
}
|
||||||
@ -344,12 +346,12 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Reader\Exception\IteratorNotRewindableException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testReadShouldThrowIfTryingToRewindRowIterator()
|
public function testReadShouldThrowIfTryingToRewindRowIterator()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IteratorNotRewindableException::class);
|
||||||
|
|
||||||
$resourcePath = $this->getResourcePath('one_sheet_with_strings.ods');
|
$resourcePath = $this->getResourcePath('one_sheet_with_strings.ods');
|
||||||
$reader = ReaderFactory::create(Type::ODS);
|
$reader = ReaderFactory::create(Type::ODS);
|
||||||
$reader->open($resourcePath);
|
$reader->open($resourcePath);
|
||||||
@ -412,24 +414,24 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testReadWithUnsupportedCustomStreamWrapper()
|
public function testReadWithUnsupportedCustomStreamWrapper()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
/** @var \Box\Spout\Reader\ODS\Reader $reader */
|
/** @var \Box\Spout\Reader\ODS\Reader $reader */
|
||||||
$reader = ReaderFactory::create(Type::ODS);
|
$reader = ReaderFactory::create(Type::ODS);
|
||||||
$reader->open('unsupported://foobar');
|
$reader->open('unsupported://foobar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testReadWithSupportedCustomStreamWrapper()
|
public function testReadWithSupportedCustomStreamWrapper()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
/** @var \Box\Spout\Reader\ODS\Reader $reader */
|
/** @var \Box\Spout\Reader\ODS\Reader $reader */
|
||||||
$reader = ReaderFactory::create(Type::ODS);
|
$reader = ReaderFactory::create(Type::ODS);
|
||||||
$reader->open('php://memory');
|
$reader->open('php://memory');
|
||||||
|
@ -2,18 +2,20 @@
|
|||||||
|
|
||||||
namespace Box\Spout\Reader;
|
namespace Box\Spout\Reader;
|
||||||
|
|
||||||
|
use Box\Spout\Common\Exception\UnsupportedTypeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ReaderFactoryTest
|
* Class ReaderFactoryTest
|
||||||
*/
|
*/
|
||||||
class ReaderFactoryTest extends \PHPUnit_Framework_TestCase
|
class ReaderFactoryTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\UnsupportedTypeException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testCreateReaderShouldThrowWithUnsupportedType()
|
public function testCreateReaderShouldThrowWithUnsupportedType()
|
||||||
{
|
{
|
||||||
|
$this->expectException(UnsupportedTypeException::class);
|
||||||
|
|
||||||
ReaderFactory::create('unsupportedType');
|
ReaderFactory::create('unsupportedType');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Box\Spout\Reader\Wrapper;
|
namespace Box\Spout\Reader\Wrapper;
|
||||||
|
|
||||||
|
use Box\Spout\Reader\Exception\XMLProcessingException;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,12 +62,12 @@ class XMLReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Reader\Exception\XMLProcessingException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testReadShouldThrowExceptionOnError()
|
public function testReadShouldThrowExceptionOnError()
|
||||||
{
|
{
|
||||||
|
$this->expectException(XMLProcessingException::class);
|
||||||
|
|
||||||
$resourcePath = $this->getResourcePath('one_sheet_with_invalid_xml_characters.xlsx');
|
$resourcePath = $this->getResourcePath('one_sheet_with_invalid_xml_characters.xlsx');
|
||||||
|
|
||||||
$xmlReader = new XMLReader();
|
$xmlReader = new XMLReader();
|
||||||
@ -81,12 +82,12 @@ class XMLReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Reader\Exception\XMLProcessingException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testNextShouldThrowExceptionOnError()
|
public function testNextShouldThrowExceptionOnError()
|
||||||
{
|
{
|
||||||
|
$this->expectException(XMLProcessingException::class);
|
||||||
|
|
||||||
// The sharedStrings.xml file in "attack_billion_laughs.xlsx" contains
|
// The sharedStrings.xml file in "attack_billion_laughs.xlsx" contains
|
||||||
// a doctype element that causes read errors
|
// a doctype element that causes read errors
|
||||||
$resourcePath = $this->getResourcePath('attack_billion_laughs.xlsx');
|
$resourcePath = $this->getResourcePath('attack_billion_laughs.xlsx');
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Box\Spout\Reader\XLSX\Helper;
|
namespace Box\Spout\Reader\XLSX\Helper;
|
||||||
|
|
||||||
|
use Box\Spout\Common\Exception\InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CellHelperTest
|
* Class CellHelperTest
|
||||||
*/
|
*/
|
||||||
@ -58,12 +60,12 @@ class CellHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\InvalidArgumentException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testGetColumnIndexFromCellIndexShouldThrowIfInvalidCellIndex()
|
public function testGetColumnIndexFromCellIndexShouldThrowIfInvalidCellIndex()
|
||||||
{
|
{
|
||||||
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
CellHelper::getColumnIndexFromCellIndex('InvalidCellIndex');
|
CellHelper::getColumnIndexFromCellIndex('InvalidCellIndex');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Box\Spout\Reader\XLSX\Manager;
|
namespace Box\Spout\Reader\XLSX\Manager;
|
||||||
|
|
||||||
|
use Box\Spout\Reader\Exception\SharedStringNotFoundException;
|
||||||
use Box\Spout\Reader\XLSX\Creator\EntityFactory;
|
use Box\Spout\Reader\XLSX\Creator\EntityFactory;
|
||||||
use Box\Spout\Reader\XLSX\Creator\HelperFactory;
|
use Box\Spout\Reader\XLSX\Creator\HelperFactory;
|
||||||
use Box\Spout\Reader\XLSX\Creator\ManagerFactory;
|
use Box\Spout\Reader\XLSX\Creator\ManagerFactory;
|
||||||
@ -57,11 +58,12 @@ class SharedStringsManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Reader\Exception\SharedStringNotFoundException
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testGetStringAtIndexShouldThrowExceptionIfStringNotFound()
|
public function testGetStringAtIndexShouldThrowExceptionIfStringNotFound()
|
||||||
{
|
{
|
||||||
|
$this->expectException(SharedStringNotFoundException::class);
|
||||||
|
|
||||||
$sharedStringsManager = $this->createSharedStringsManager();
|
$sharedStringsManager = $this->createSharedStringsManager();
|
||||||
$sharedStringsManager->extractSharedStrings();
|
$sharedStringsManager->extractSharedStrings();
|
||||||
$sharedStringsManager->getStringAtIndex(PHP_INT_MAX);
|
$sharedStringsManager->getStringAtIndex(PHP_INT_MAX);
|
||||||
|
@ -29,13 +29,14 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider dataProviderForTestReadShouldThrowException
|
* @dataProvider dataProviderForTestReadShouldThrowException
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
|
||||||
*
|
*
|
||||||
* @param string $filePath
|
* @param string $filePath
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testReadShouldThrowException($filePath)
|
public function testReadShouldThrowException($filePath)
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
// using @ to prevent warnings/errors from being displayed
|
// using @ to prevent warnings/errors from being displayed
|
||||||
@$this->getAllRowsForFile($filePath);
|
@$this->getAllRowsForFile($filePath);
|
||||||
}
|
}
|
||||||
@ -568,24 +569,24 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testReadWithUnsupportedCustomStreamWrapper()
|
public function testReadWithUnsupportedCustomStreamWrapper()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
/** @var \Box\Spout\Reader\XLSX\Reader $reader */
|
/** @var \Box\Spout\Reader\XLSX\Reader $reader */
|
||||||
$reader = ReaderFactory::create(Type::XLSX);
|
$reader = ReaderFactory::create(Type::XLSX);
|
||||||
$reader->open('unsupported://foobar');
|
$reader->open('unsupported://foobar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testReadWithSupportedCustomStreamWrapper()
|
public function testReadWithSupportedCustomStreamWrapper()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
/** @var \Box\Spout\Reader\XLSX\Reader $reader */
|
/** @var \Box\Spout\Reader\XLSX\Reader $reader */
|
||||||
$reader = ReaderFactory::create(Type::XLSX);
|
$reader = ReaderFactory::create(Type::XLSX);
|
||||||
$reader->open('php://memory');
|
$reader->open('php://memory');
|
||||||
|
@ -2,10 +2,13 @@
|
|||||||
|
|
||||||
namespace Box\Spout\Writer\CSV;
|
namespace Box\Spout\Writer\CSV;
|
||||||
|
|
||||||
|
use Box\Spout\Common\Exception\InvalidArgumentException;
|
||||||
|
use Box\Spout\Common\Exception\IOException;
|
||||||
use Box\Spout\Common\Helper\EncodingHelper;
|
use Box\Spout\Common\Helper\EncodingHelper;
|
||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use Box\Spout\Writer\Common\Entity\Row;
|
use Box\Spout\Writer\Common\Entity\Row;
|
||||||
|
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
use Box\Spout\Writer\WriterFactory;
|
use Box\Spout\Writer\WriterFactory;
|
||||||
|
|
||||||
@ -18,10 +21,12 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
use RowCreationHelper;
|
use RowCreationHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testWriteShouldThrowExceptionIfCannotOpenFileForWriting()
|
public function testWriteShouldThrowExceptionIfCannotOpenFileForWriting()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
$fileName = 'file_that_wont_be_written.csv';
|
$fileName = 'file_that_wont_be_written.csv';
|
||||||
$this->createUnwritableFolderIfNeeded();
|
$this->createUnwritableFolderIfNeeded();
|
||||||
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
||||||
@ -33,30 +38,36 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterNotOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testWriteShouldThrowExceptionIfCallAddRowBeforeOpeningWriter()
|
public function testWriteShouldThrowExceptionIfCallAddRowBeforeOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = WriterFactory::create(Type::CSV);
|
$writer = WriterFactory::create(Type::CSV);
|
||||||
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
||||||
$writer->close();
|
$writer->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterNotOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testWriteShouldThrowExceptionIfCallAddRowsBeforeOpeningWriter()
|
public function testWriteShouldThrowExceptionIfCallAddRowsBeforeOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = WriterFactory::create(Type::CSV);
|
$writer = WriterFactory::create(Type::CSV);
|
||||||
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
$writer->addRow($this->createRowFromValues(['csv--11', 'csv--12']));
|
||||||
$writer->close();
|
$writer->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\InvalidArgumentException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddRowsShouldThrowExceptionIfRowsAreNotArrayOfArrays()
|
public function testAddRowsShouldThrowExceptionIfRowsAreNotArrayOfArrays()
|
||||||
{
|
{
|
||||||
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
$writer = WriterFactory::create(Type::CSV);
|
$writer = WriterFactory::create(Type::CSV);
|
||||||
$writer->addRows([['csv--11', 'csv--12']]);
|
$writer->addRows([['csv--11', 'csv--12']]);
|
||||||
$writer->close();
|
$writer->close();
|
||||||
|
@ -4,6 +4,7 @@ namespace Box\Spout\Writer\Common\Entity;
|
|||||||
|
|
||||||
use Box\Spout\Common\Helper\StringHelper;
|
use Box\Spout\Common\Helper\StringHelper;
|
||||||
use Box\Spout\Writer\Common\Manager\SheetManager;
|
use Box\Spout\Writer\Common\Manager\SheetManager;
|
||||||
|
use Box\Spout\Writer\Exception\InvalidSheetNameException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class SheetTest
|
* Class SheetTest
|
||||||
@ -78,13 +79,14 @@ class SheetTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider dataProviderForInvalidSheetNames
|
* @dataProvider dataProviderForInvalidSheetNames
|
||||||
* @expectedException \Box\Spout\Writer\Exception\InvalidSheetNameException
|
|
||||||
*
|
*
|
||||||
* @param string $customSheetName
|
* @param string $customSheetName
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testSetSheetNameShouldThrowOnInvalidName($customSheetName)
|
public function testSetSheetNameShouldThrowOnInvalidName($customSheetName)
|
||||||
{
|
{
|
||||||
|
$this->expectException(InvalidSheetNameException::class);
|
||||||
|
|
||||||
$sheet = $this->createSheet(0, 'workbookId1');
|
$sheet = $this->createSheet(0, 'workbookId1');
|
||||||
$sheet->setName($customSheetName);
|
$sheet->setName($customSheetName);
|
||||||
}
|
}
|
||||||
@ -101,11 +103,12 @@ class SheetTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\InvalidSheetNameException
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testSetSheetNameShouldThrowWhenNameIsAlreadyUsed()
|
public function testSetSheetNameShouldThrowWhenNameIsAlreadyUsed()
|
||||||
{
|
{
|
||||||
|
$this->expectException(InvalidSheetNameException::class);
|
||||||
|
|
||||||
$customSheetName = 'Sheet name';
|
$customSheetName = 'Sheet name';
|
||||||
|
|
||||||
$sheet = $this->createSheet(0, 'workbookId1');
|
$sheet = $this->createSheet(0, 'workbookId1');
|
||||||
|
@ -6,6 +6,9 @@ use Box\Spout\Writer\Common\Creator\Style\BorderBuilder;
|
|||||||
use Box\Spout\Writer\Common\Entity\Style\Border;
|
use Box\Spout\Writer\Common\Entity\Style\Border;
|
||||||
use Box\Spout\Writer\Common\Entity\Style\BorderPart;
|
use Box\Spout\Writer\Common\Entity\Style\BorderPart;
|
||||||
use Box\Spout\Writer\Common\Entity\Style\Color;
|
use Box\Spout\Writer\Common\Entity\Style\Color;
|
||||||
|
use Box\Spout\Writer\Exception\Border\InvalidNameException;
|
||||||
|
use Box\Spout\Writer\Exception\Border\InvalidStyleException;
|
||||||
|
use Box\Spout\Writer\Exception\Border\InvalidWidthException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BorderTest
|
* Class BorderTest
|
||||||
@ -24,26 +27,32 @@ class BorderTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\Border\InvalidNameException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testInvalidBorderPart()
|
public function testInvalidBorderPart()
|
||||||
{
|
{
|
||||||
|
$this->expectException(InvalidNameException::class);
|
||||||
|
|
||||||
new BorderPart('invalid');
|
new BorderPart('invalid');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\Border\InvalidStyleException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testInvalidBorderPartStyle()
|
public function testInvalidBorderPartStyle()
|
||||||
{
|
{
|
||||||
|
$this->expectException(InvalidStyleException::class);
|
||||||
|
|
||||||
new BorderPart(Border::LEFT, Color::BLACK, Border::WIDTH_THIN, 'invalid');
|
new BorderPart(Border::LEFT, Color::BLACK, Border::WIDTH_THIN, 'invalid');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\Border\InvalidWidthException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testInvalidBorderPartWidth()
|
public function testInvalidBorderPartWidth()
|
||||||
{
|
{
|
||||||
|
$this->expectException(InvalidWidthException::class);
|
||||||
|
|
||||||
new BorderPart(Border::LEFT, Color::BLACK, 'invalid', Border::STYLE_DASHED);
|
new BorderPart(Border::LEFT, Color::BLACK, 'invalid', Border::STYLE_DASHED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Box\Spout\Writer\Common\Entity\Style;
|
namespace Box\Spout\Writer\Common\Entity\Style;
|
||||||
|
|
||||||
|
use Box\Spout\Writer\Exception\InvalidColorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ColorTest
|
* Class ColorTest
|
||||||
*/
|
*/
|
||||||
@ -76,7 +78,6 @@ class ColorTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider dataProviderForTestRGBAInvalidColorComponents
|
* @dataProvider dataProviderForTestRGBAInvalidColorComponents
|
||||||
* @expectedException \Box\Spout\Writer\Exception\InvalidColorException
|
|
||||||
*
|
*
|
||||||
* @param int $red
|
* @param int $red
|
||||||
* @param int $green
|
* @param int $green
|
||||||
@ -85,6 +86,8 @@ class ColorTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRGBInvalidColorComponents($red, $green, $blue)
|
public function testRGBInvalidColorComponents($red, $green, $blue)
|
||||||
{
|
{
|
||||||
|
$this->expectException(InvalidColorException::class);
|
||||||
|
|
||||||
Color::rgb($red, $green, $blue);
|
Color::rgb($red, $green, $blue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace Box\Spout\Writer\ODS;
|
|||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use Box\Spout\Writer\Common\Entity\Sheet;
|
use Box\Spout\Writer\Common\Entity\Sheet;
|
||||||
|
use Box\Spout\Writer\Exception\InvalidSheetNameException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
use Box\Spout\Writer\WriterFactory;
|
use Box\Spout\Writer\WriterFactory;
|
||||||
|
|
||||||
@ -53,11 +54,12 @@ class SheetTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\InvalidSheetNameException
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testSetSheetNameShouldThrowWhenNameIsAlreadyUsed()
|
public function testSetSheetNameShouldThrowWhenNameIsAlreadyUsed()
|
||||||
{
|
{
|
||||||
|
$this->expectException(InvalidSheetNameException::class);
|
||||||
|
|
||||||
$fileName = 'test_set_name_with_non_unique_name.ods';
|
$fileName = 'test_set_name_with_non_unique_name.ods';
|
||||||
$this->createGeneratedFolderIfNeeded($fileName);
|
$this->createGeneratedFolderIfNeeded($fileName);
|
||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Box\Spout\Writer\ODS;
|
namespace Box\Spout\Writer\ODS;
|
||||||
|
|
||||||
|
use Box\Spout\Common\Exception\InvalidArgumentException;
|
||||||
|
use Box\Spout\Common\Exception\IOException;
|
||||||
use Box\Spout\Common\Exception\SpoutException;
|
use Box\Spout\Common\Exception\SpoutException;
|
||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\Reader\Wrapper\XMLReader;
|
use Box\Spout\Reader\Wrapper\XMLReader;
|
||||||
@ -9,6 +11,8 @@ use Box\Spout\TestUsingResource;
|
|||||||
use Box\Spout\Writer\Common\Entity\Cell;
|
use Box\Spout\Writer\Common\Entity\Cell;
|
||||||
use Box\Spout\Writer\Common\Entity\Row;
|
use Box\Spout\Writer\Common\Entity\Row;
|
||||||
use Box\Spout\Writer\Common\Helper\ZipHelper;
|
use Box\Spout\Writer\Common\Helper\ZipHelper;
|
||||||
|
use Box\Spout\Writer\Exception\WriterAlreadyOpenedException;
|
||||||
|
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
use Box\Spout\Writer\WriterFactory;
|
use Box\Spout\Writer\WriterFactory;
|
||||||
|
|
||||||
@ -21,10 +25,12 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
use RowCreationHelper;
|
use RowCreationHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddRowShouldThrowExceptionIfCannotOpenAFileForWriting()
|
public function testAddRowShouldThrowExceptionIfCannotOpenAFileForWriting()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
$fileName = 'file_that_wont_be_written.ods';
|
$fileName = 'file_that_wont_be_written.ods';
|
||||||
$this->createUnwritableFolderIfNeeded();
|
$this->createUnwritableFolderIfNeeded();
|
||||||
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
||||||
@ -34,28 +40,34 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterNotOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddRowShouldThrowExceptionIfCallAddRowBeforeOpeningWriter()
|
public function testAddRowShouldThrowExceptionIfCallAddRowBeforeOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = WriterFactory::create(Type::ODS);
|
$writer = WriterFactory::create(Type::ODS);
|
||||||
$writer->addRow($this->createRowFromValues(['ods--11', 'ods--12']));
|
$writer->addRow($this->createRowFromValues(['ods--11', 'ods--12']));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterNotOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddRowShouldThrowExceptionIfCalledBeforeOpeningWriter()
|
public function testAddRowShouldThrowExceptionIfCalledBeforeOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = WriterFactory::create(Type::ODS);
|
$writer = WriterFactory::create(Type::ODS);
|
||||||
$writer->addRows([$this->createRowFromValues(['ods--11', 'ods--12'])]);
|
$writer->addRows([$this->createRowFromValues(['ods--11', 'ods--12'])]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterAlreadyOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testSetTempFolderShouldThrowExceptionIfCalledAfterOpeningWriter()
|
public function testSetTempFolderShouldThrowExceptionIfCalledAfterOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterAlreadyOpenedException::class);
|
||||||
|
|
||||||
$fileName = 'file_that_wont_be_written.ods';
|
$fileName = 'file_that_wont_be_written.ods';
|
||||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
@ -67,10 +79,12 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterAlreadyOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testSetShouldCreateNewSheetsAutomaticallyShouldThrowExceptionIfCalledAfterOpeningWriter()
|
public function testSetShouldCreateNewSheetsAutomaticallyShouldThrowExceptionIfCalledAfterOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterAlreadyOpenedException::class);
|
||||||
|
|
||||||
$fileName = 'file_that_wont_be_written.ods';
|
$fileName = 'file_that_wont_be_written.ods';
|
||||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
@ -82,10 +96,12 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\InvalidArgumentException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddRowShouldThrowExceptionIfUnsupportedDataTypePassedIn()
|
public function testAddRowShouldThrowExceptionIfUnsupportedDataTypePassedIn()
|
||||||
{
|
{
|
||||||
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
$fileName = 'test_add_row_should_throw_exception_if_unsupported_data_type_passed_in.ods';
|
$fileName = 'test_add_row_should_throw_exception_if_unsupported_data_type_passed_in.ods';
|
||||||
$dataRows = [
|
$dataRows = [
|
||||||
$this->createRowFromValues([new \stdClass()]),
|
$this->createRowFromValues([new \stdClass()]),
|
||||||
|
@ -11,6 +11,7 @@ use Box\Spout\Writer\Common\Entity\Row;
|
|||||||
use Box\Spout\Writer\Common\Entity\Style\Border;
|
use Box\Spout\Writer\Common\Entity\Style\Border;
|
||||||
use Box\Spout\Writer\Common\Entity\Style\Color;
|
use Box\Spout\Writer\Common\Entity\Style\Color;
|
||||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||||
|
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
use Box\Spout\Writer\WriterFactory;
|
use Box\Spout\Writer\WriterFactory;
|
||||||
|
|
||||||
@ -34,19 +35,23 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterNotOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddRowWithStyleShouldThrowExceptionIfCallAddRowBeforeOpeningWriter()
|
public function testAddRowWithStyleShouldThrowExceptionIfCallAddRowBeforeOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = WriterFactory::create(Type::ODS);
|
$writer = WriterFactory::create(Type::ODS);
|
||||||
$writer->addRow($this->createStyledRowFromValues(['ods--11', 'ods--12'], $this->defaultStyle));
|
$writer->addRow($this->createStyledRowFromValues(['ods--11', 'ods--12'], $this->defaultStyle));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterNotOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddRowWithStyleShouldThrowExceptionIfCalledBeforeOpeningWriter()
|
public function testAddRowWithStyleShouldThrowExceptionIfCalledBeforeOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = WriterFactory::create(Type::ODS);
|
$writer = WriterFactory::create(Type::ODS);
|
||||||
$writer->addRow($this->createStyledRowFromValues(['ods--11', 'ods--12'], $this->defaultStyle));
|
$writer->addRow($this->createStyledRowFromValues(['ods--11', 'ods--12'], $this->defaultStyle));
|
||||||
}
|
}
|
||||||
|
@ -2,18 +2,20 @@
|
|||||||
|
|
||||||
namespace Box\Spout\Writer;
|
namespace Box\Spout\Writer;
|
||||||
|
|
||||||
|
use Box\Spout\Common\Exception\UnsupportedTypeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class WriterFactoryTest
|
* Class WriterFactoryTest
|
||||||
*/
|
*/
|
||||||
class WriterFactoryTest extends \PHPUnit_Framework_TestCase
|
class WriterFactoryTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\UnsupportedTypeException
|
|
||||||
*
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testCreateWriterShouldThrowWithUnsupportedType()
|
public function testCreateWriterShouldThrowWithUnsupportedType()
|
||||||
{
|
{
|
||||||
|
$this->expectException(UnsupportedTypeException::class);
|
||||||
|
|
||||||
WriterFactory::create('unsupportedType');
|
WriterFactory::create('unsupportedType');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace Box\Spout\Writer\XLSX;
|
|||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use Box\Spout\Writer\Common\Entity\Sheet;
|
use Box\Spout\Writer\Common\Entity\Sheet;
|
||||||
|
use Box\Spout\Writer\Exception\InvalidSheetNameException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
use Box\Spout\Writer\WriterFactory;
|
use Box\Spout\Writer\WriterFactory;
|
||||||
|
|
||||||
@ -53,11 +54,12 @@ class SheetTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\InvalidSheetNameException
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testSetSheetNameShouldThrowWhenNameIsAlreadyUsed()
|
public function testSetSheetNameShouldThrowWhenNameIsAlreadyUsed()
|
||||||
{
|
{
|
||||||
|
$this->expectException(InvalidSheetNameException::class);
|
||||||
|
|
||||||
$fileName = 'test_set_name_with_non_unique_name.xlsx';
|
$fileName = 'test_set_name_with_non_unique_name.xlsx';
|
||||||
$this->createGeneratedFolderIfNeeded($fileName);
|
$this->createGeneratedFolderIfNeeded($fileName);
|
||||||
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
$resourcePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
@ -2,10 +2,14 @@
|
|||||||
|
|
||||||
namespace Box\Spout\Writer\XLSX;
|
namespace Box\Spout\Writer\XLSX;
|
||||||
|
|
||||||
|
use Box\Spout\Common\Exception\InvalidArgumentException;
|
||||||
|
use Box\Spout\Common\Exception\IOException;
|
||||||
use Box\Spout\Common\Exception\SpoutException;
|
use Box\Spout\Common\Exception\SpoutException;
|
||||||
use Box\Spout\Common\Type;
|
use Box\Spout\Common\Type;
|
||||||
use Box\Spout\TestUsingResource;
|
use Box\Spout\TestUsingResource;
|
||||||
use Box\Spout\Writer\Common\Entity\Row;
|
use Box\Spout\Writer\Common\Entity\Row;
|
||||||
|
use Box\Spout\Writer\Exception\WriterAlreadyOpenedException;
|
||||||
|
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
use Box\Spout\Writer\WriterFactory;
|
use Box\Spout\Writer\WriterFactory;
|
||||||
use Box\Spout\Writer\XLSX\Manager\WorksheetManager;
|
use Box\Spout\Writer\XLSX\Manager\WorksheetManager;
|
||||||
@ -19,10 +23,12 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
use RowCreationHelper;
|
use RowCreationHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\IOException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddRowShouldThrowExceptionIfCannotOpenAFileForWriting()
|
public function testAddRowShouldThrowExceptionIfCannotOpenAFileForWriting()
|
||||||
{
|
{
|
||||||
|
$this->expectException(IOException::class);
|
||||||
|
|
||||||
$fileName = 'file_that_wont_be_written.xlsx';
|
$fileName = 'file_that_wont_be_written.xlsx';
|
||||||
$this->createUnwritableFolderIfNeeded();
|
$this->createUnwritableFolderIfNeeded();
|
||||||
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
$filePath = $this->getGeneratedUnwritableResourcePath($fileName);
|
||||||
@ -32,28 +38,34 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterNotOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddRowShouldThrowExceptionIfCallAddRowBeforeOpeningWriter()
|
public function testAddRowShouldThrowExceptionIfCallAddRowBeforeOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = WriterFactory::create(Type::XLSX);
|
$writer = WriterFactory::create(Type::XLSX);
|
||||||
$writer->addRow($this->createRowFromValues(['xlsx--11', 'xlsx--12']));
|
$writer->addRow($this->createRowFromValues(['xlsx--11', 'xlsx--12']));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterNotOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddRowShouldThrowExceptionIfCalledBeforeOpeningWriter()
|
public function testAddRowShouldThrowExceptionIfCalledBeforeOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = WriterFactory::create(Type::XLSX);
|
$writer = WriterFactory::create(Type::XLSX);
|
||||||
$writer->addRows($this->createRowsFromValues([['xlsx--11', 'xlsx--12']]));
|
$writer->addRows($this->createRowsFromValues([['xlsx--11', 'xlsx--12']]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterAlreadyOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testSetTempFolderShouldThrowExceptionIfCalledAfterOpeningWriter()
|
public function testSetTempFolderShouldThrowExceptionIfCalledAfterOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterAlreadyOpenedException::class);
|
||||||
|
|
||||||
$fileName = 'file_that_wont_be_written.xlsx';
|
$fileName = 'file_that_wont_be_written.xlsx';
|
||||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
@ -65,10 +77,12 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterAlreadyOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testSetShouldUseInlineStringsShouldThrowExceptionIfCalledAfterOpeningWriter()
|
public function testSetShouldUseInlineStringsShouldThrowExceptionIfCalledAfterOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterAlreadyOpenedException::class);
|
||||||
|
|
||||||
$fileName = 'file_that_wont_be_written.xlsx';
|
$fileName = 'file_that_wont_be_written.xlsx';
|
||||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
@ -80,10 +94,12 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterAlreadyOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testsetShouldCreateNewSheetsAutomaticallyShouldThrowExceptionIfCalledAfterOpeningWriter()
|
public function testsetShouldCreateNewSheetsAutomaticallyShouldThrowExceptionIfCalledAfterOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterAlreadyOpenedException::class);
|
||||||
|
|
||||||
$fileName = 'file_that_wont_be_written.xlsx';
|
$fileName = 'file_that_wont_be_written.xlsx';
|
||||||
$filePath = $this->getGeneratedResourcePath($fileName);
|
$filePath = $this->getGeneratedResourcePath($fileName);
|
||||||
|
|
||||||
@ -95,10 +111,12 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\InvalidArgumentException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddRowShouldThrowExceptionIfUnsupportedDataTypePassedIn()
|
public function testAddRowShouldThrowExceptionIfUnsupportedDataTypePassedIn()
|
||||||
{
|
{
|
||||||
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
$fileName = 'test_add_row_should_throw_exception_if_unsupported_data_type_passed_in.xlsx';
|
$fileName = 'test_add_row_should_throw_exception_if_unsupported_data_type_passed_in.xlsx';
|
||||||
$dataRows = [
|
$dataRows = [
|
||||||
[str_repeat('a', WorksheetManager::MAX_CHARACTERS_PER_CELL + 1)],
|
[str_repeat('a', WorksheetManager::MAX_CHARACTERS_PER_CELL + 1)],
|
||||||
@ -108,10 +126,12 @@ class WriterTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Common\Exception\InvalidArgumentException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddRowShouldThrowExceptionIfWritingStringExceedingMaxNumberOfCharactersAllowedPerCell()
|
public function testAddRowShouldThrowExceptionIfWritingStringExceedingMaxNumberOfCharactersAllowedPerCell()
|
||||||
{
|
{
|
||||||
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
$fileName = 'test_add_row_should_throw_exception_if_string_exceeds_max_num_chars_allowed_per_cell.xlsx';
|
$fileName = 'test_add_row_should_throw_exception_if_string_exceeds_max_num_chars_allowed_per_cell.xlsx';
|
||||||
$dataRows = $this->createRowsFromValues([
|
$dataRows = $this->createRowsFromValues([
|
||||||
[new \stdClass()],
|
[new \stdClass()],
|
||||||
|
@ -12,6 +12,7 @@ use Box\Spout\Writer\Common\Entity\Style\Border;
|
|||||||
use Box\Spout\Writer\Common\Entity\Style\Color;
|
use Box\Spout\Writer\Common\Entity\Style\Color;
|
||||||
use Box\Spout\Writer\Common\Entity\Style\Style;
|
use Box\Spout\Writer\Common\Entity\Style\Style;
|
||||||
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
|
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
|
||||||
|
use Box\Spout\Writer\Exception\WriterNotOpenedException;
|
||||||
use Box\Spout\Writer\RowCreationHelper;
|
use Box\Spout\Writer\RowCreationHelper;
|
||||||
use Box\Spout\Writer\WriterFactory;
|
use Box\Spout\Writer\WriterFactory;
|
||||||
use Box\Spout\Writer\XLSX\Manager\OptionsManager;
|
use Box\Spout\Writer\XLSX\Manager\OptionsManager;
|
||||||
@ -36,19 +37,23 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterNotOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddRowWithStyleShouldThrowExceptionIfCallAddRowBeforeOpeningWriter()
|
public function testAddRowWithStyleShouldThrowExceptionIfCallAddRowBeforeOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = WriterFactory::create(Type::XLSX);
|
$writer = WriterFactory::create(Type::XLSX);
|
||||||
$writer->addRow($this->createStyledRowFromValues(['xlsx--11', 'xlsx--12'], $this->defaultStyle));
|
$writer->addRow($this->createStyledRowFromValues(['xlsx--11', 'xlsx--12'], $this->defaultStyle));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Box\Spout\Writer\Exception\WriterNotOpenedException
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddRowWithStyleShouldThrowExceptionIfCalledBeforeOpeningWriter()
|
public function testAddRowWithStyleShouldThrowExceptionIfCalledBeforeOpeningWriter()
|
||||||
{
|
{
|
||||||
|
$this->expectException(WriterNotOpenedException::class);
|
||||||
|
|
||||||
$writer = WriterFactory::create(Type::XLSX);
|
$writer = WriterFactory::create(Type::XLSX);
|
||||||
$writer->addRow($this->createStyledRowFromValues(['xlsx--11', 'xlsx--12'], $this->defaultStyle));
|
$writer->addRow($this->createStyledRowFromValues(['xlsx--11', 'xlsx--12'], $this->defaultStyle));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user