Remove @expectedException annotation

This commit is contained in:
Adrien Loison committed 2017-11-05 02:21:09 +01:00
1 parent 7274226b75
commit 3851e05f83
20 files changed
+173 -74

No files matched your search

+12 -10
View File
@@ -3,10 +3,12 @@
namespace Box\Spout\Reader\CSV;
use Box\Spout\Common\Creator\HelperFactory;
use Box\Spout\Common\Exception\IOException;
use Box\Spout\Common\Helper\EncodingHelper;
use Box\Spout\Common\Helper\GlobalFunctionsHelper;
use Box\Spout\Reader\CSV\Creator\EntityFactory;
use Box\Spout\Reader\CSV\Manager\OptionsManager;
use Box\Spout\Reader\Exception\ReaderNotOpenedException;
use Box\Spout\Reader\ReaderInterface;
use Box\Spout\TestUsingResource;
@@ -18,32 +20,32 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
use TestUsingResource;
/**
* @expectedException \Box\Spout\Common\Exception\IOException
*
* @return void
*/
public function testOpenShouldThrowExceptionIfFileDoesNotExist()
{
$this->expectException(IOException::class);
$this->createCSVReader()->open('/path/to/fake/file.csv');
}
/**
* @expectedException \Box\Spout\Reader\Exception\ReaderNotOpenedException
*
* @return void
*/
public function testOpenShouldThrowExceptionIfTryingToReadBeforeOpeningReader()
{
$this->expectException(ReaderNotOpenedException::class);
$this->createCSVReader()->getSheetIterator();
}
/**
* @expectedException \Box\Spout\Common\Exception\IOException
*
* @return void
*/
public function testOpenShouldThrowExceptionIfFileNotReadable()
{
$this->expectException(IOException::class);
/** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper|\PHPUnit_Framework_MockObject_MockObject $helperStub */
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
->setMethods(['is_readable'])
@@ -57,12 +59,12 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException \Box\Spout\Common\Exception\IOException
*
* @return void
*/
public function testOpenShouldThrowExceptionIfCannotOpenFile()
{
$this->expectException(IOException::class);
/** @var \Box\Spout\Common\Helper\GlobalFunctionsHelper|\PHPUnit_Framework_MockObject_MockObject $helperStub */
$helperStub = $this->getMockBuilder('\Box\Spout\Common\Helper\GlobalFunctionsHelper')
->setMethods(['fopen'])
@@ -449,12 +451,12 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException \Box\Spout\Common\Exception\IOException
*
* @return void
*/
public function testReadWithUnsupportedCustomStreamWrapper()
{
$this->expectException(IOException::class);
/** @var \Box\Spout\Reader\CSV\Reader $reader */
$reader = $this->createCSVReader();
$reader->open('unsupported://foobar');
+9 -7
View File
@@ -4,6 +4,7 @@ namespace Box\Spout\Reader\ODS;
use Box\Spout\Common\Exception\IOException;
use Box\Spout\Common\Type;
use Box\Spout\Reader\Exception\IteratorNotRewindableException;
use Box\Spout\Reader\ReaderFactory;
use Box\Spout\TestUsingResource;
@@ -27,13 +28,14 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider dataProviderForTestReadShouldThrowException
* @expectedException \Box\Spout\Common\Exception\IOException
*
* @param string $filePath
* @return void
*/
public function testReadShouldThrowException($filePath)
{
$this->expectException(IOException::class);
// using @ to prevent warnings/errors from being displayed
@$this->getAllRowsForFile($filePath);
}
@@ -344,12 +346,12 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException \Box\Spout\Reader\Exception\IteratorNotRewindableException
*
* @return void
*/
public function testReadShouldThrowIfTryingToRewindRowIterator()
{
$this->expectException(IteratorNotRewindableException::class);
$resourcePath = $this->getResourcePath('one_sheet_with_strings.ods');
$reader = ReaderFactory::create(Type::ODS);
$reader->open($resourcePath);
@@ -412,24 +414,24 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException \Box\Spout\Common\Exception\IOException
*
* @return void
*/
public function testReadWithUnsupportedCustomStreamWrapper()
{
$this->expectException(IOException::class);
/** @var \Box\Spout\Reader\ODS\Reader $reader */
$reader = ReaderFactory::create(Type::ODS);
$reader->open('unsupported://foobar');
}
/**
* @expectedException \Box\Spout\Common\Exception\IOException
*
* @return void
*/
public function testReadWithSupportedCustomStreamWrapper()
{
$this->expectException(IOException::class);
/** @var \Box\Spout\Reader\ODS\Reader $reader */
$reader = ReaderFactory::create(Type::ODS);
$reader->open('php://memory');
+4 -2
View File
@@ -2,18 +2,20 @@
namespace Box\Spout\Reader;
use Box\Spout\Common\Exception\UnsupportedTypeException;
/**
* Class ReaderFactoryTest
*/
class ReaderFactoryTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \Box\Spout\Common\Exception\UnsupportedTypeException
*
* @return void
*/
public function testCreateReaderShouldThrowWithUnsupportedType()
{
$this->expectException(UnsupportedTypeException::class);
ReaderFactory::create('unsupportedType');
}
}
+5 -4
View File
@@ -2,6 +2,7 @@
namespace Box\Spout\Reader\Wrapper;
use Box\Spout\Reader\Exception\XMLProcessingException;
use Box\Spout\TestUsingResource;
/**
@@ -61,12 +62,12 @@ class XMLReaderTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException \Box\Spout\Reader\Exception\XMLProcessingException
*
* @return void
*/
public function testReadShouldThrowExceptionOnError()
{
$this->expectException(XMLProcessingException::class);
$resourcePath = $this->getResourcePath('one_sheet_with_invalid_xml_characters.xlsx');
$xmlReader = new XMLReader();
@@ -81,12 +82,12 @@ class XMLReaderTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException \Box\Spout\Reader\Exception\XMLProcessingException
*
* @return void
*/
public function testNextShouldThrowExceptionOnError()
{
$this->expectException(XMLProcessingException::class);
// The sharedStrings.xml file in "attack_billion_laughs.xlsx" contains
// a doctype element that causes read errors
$resourcePath = $this->getResourcePath('attack_billion_laughs.xlsx');
@@ -2,6 +2,8 @@
namespace Box\Spout\Reader\XLSX\Helper;
use Box\Spout\Common\Exception\InvalidArgumentException;
/**
* Class CellHelperTest
*/
@@ -58,12 +60,12 @@ class CellHelperTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException \Box\Spout\Common\Exception\InvalidArgumentException
*
* @return void
*/
public function testGetColumnIndexFromCellIndexShouldThrowIfInvalidCellIndex()
{
$this->expectException(InvalidArgumentException::class);
CellHelper::getColumnIndexFromCellIndex('InvalidCellIndex');
}
}
@@ -2,6 +2,7 @@
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\HelperFactory;
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
*/
public function testGetStringAtIndexShouldThrowExceptionIfStringNotFound()
{
$this->expectException(SharedStringNotFoundException::class);
$sharedStringsManager = $this->createSharedStringsManager();
$sharedStringsManager->extractSharedStrings();
$sharedStringsManager->getStringAtIndex(PHP_INT_MAX);
+6 -5
View File
@@ -29,13 +29,14 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider dataProviderForTestReadShouldThrowException
* @expectedException \Box\Spout\Common\Exception\IOException
*
* @param string $filePath
* @return void
*/
public function testReadShouldThrowException($filePath)
{
$this->expectException(IOException::class);
// using @ to prevent warnings/errors from being displayed
@$this->getAllRowsForFile($filePath);
}
@@ -568,24 +569,24 @@ class ReaderTest extends \PHPUnit_Framework_TestCase
}
/**
* @expectedException \Box\Spout\Common\Exception\IOException
*
* @return void
*/
public function testReadWithUnsupportedCustomStreamWrapper()
{
$this->expectException(IOException::class);
/** @var \Box\Spout\Reader\XLSX\Reader $reader */
$reader = ReaderFactory::create(Type::XLSX);
$reader->open('unsupported://foobar');
}
/**
* @expectedException \Box\Spout\Common\Exception\IOException
*
* @return void
*/
public function testReadWithSupportedCustomStreamWrapper()
{
$this->expectException(IOException::class);
/** @var \Box\Spout\Reader\XLSX\Reader $reader */
$reader = ReaderFactory::create(Type::XLSX);
$reader->open('php://memory');