From 3945e2d5f4298725688965baa0d79741f882eff2 Mon Sep 17 00:00:00 2001 From: Cyril VERLOOP Date: Sat, 12 Oct 2019 13:03:24 +0200 Subject: [PATCH] Fix PHPUnit 9 compatibility for expectedException. --- tests/Unit/DirectoryCleanerTest.php | 9 +++++---- tests/Unit/config/GlobalConfigTest.php | 8 ++++---- tests/Unit/docblock/DocBlockTest.php | 4 +++- tests/Unit/docblock/FactoryTest.php | 7 +++++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/Unit/DirectoryCleanerTest.php b/tests/Unit/DirectoryCleanerTest.php index 719ea472..d9e66f2e 100644 --- a/tests/Unit/DirectoryCleanerTest.php +++ b/tests/Unit/DirectoryCleanerTest.php @@ -1,6 +1,8 @@ cleaner = new DirectoryCleaner(); } - /** - * @expectedException \TheSeer\phpDox\DirectoryCleanerException - * @expectedExceptionCode \TheSeer\phpDox\DirectoryCleanerException::SecurityLimitation - */ public function testTryingToDeleteAShortPathThrowsException(): void { + self::expectException(DirectoryCleanerException::class); + self::expectExceptionCode(DirectoryCleanerException::SecurityLimitation); + $this->cleaner->process(new FileInfo('/tmp')); } diff --git a/tests/Unit/config/GlobalConfigTest.php b/tests/Unit/config/GlobalConfigTest.php index 21034491..06375480 100644 --- a/tests/Unit/config/GlobalConfigTest.php +++ b/tests/Unit/config/GlobalConfigTest.php @@ -2,6 +2,7 @@ namespace TheSeer\phpDox; use TheSeer\fDOM\fDOMDocument; +use TheSeer\phpDox\ConfigException; /** * Class GlobalConfigTest @@ -40,11 +41,10 @@ public function __construct($name = null, array $data = [], $dataName = '') { $this->baseDir = \realpath(__DIR__ . '/../../data/config') . '/'; } - /** - * @expectedException \TheSeer\phpDox\ConfigException - * @expectedExceptionCode \TheSeer\phpDox\ConfigException::InvalidDataStructure - */ public function testTryingToLoadInvalidConfigThrowsException(): void { + self::expectException(ConfigException::class); + self::expectExceptionCode(ConfigException::InvalidDataStructure); + $this->init('broken'); } diff --git a/tests/Unit/docblock/DocBlockTest.php b/tests/Unit/docblock/DocBlockTest.php index 8a9b62d2..9c20ed5a 100644 --- a/tests/Unit/docblock/DocBlockTest.php +++ b/tests/Unit/docblock/DocBlockTest.php @@ -3,6 +3,7 @@ use PHPUnit\Framework\TestCase; use TheSeer\fDOM\fDOMDocument; +use TheSeer\phpDox\DocBlock\DocBlockException; /** * Class DocBlockTest @@ -58,10 +59,11 @@ public function testSameTypeElementCanBeAddedMultipleTimes(): void { } /** - * @expectedException \TheSeer\phpDox\DocBlock\DocBlockException * @covers \TheSeer\phpDox\DocBlock\DocBlock::getElementByName */ public function testTryingToGetANonExistingElementThrowsException(): void { + self::expectException(DocBlockException::class); + $this->docBlock->getElementByName('non-set'); } diff --git a/tests/Unit/docblock/FactoryTest.php b/tests/Unit/docblock/FactoryTest.php index 801ff7e3..22df3744 100644 --- a/tests/Unit/docblock/FactoryTest.php +++ b/tests/Unit/docblock/FactoryTest.php @@ -3,6 +3,7 @@ use TheSeer\fDOM\fDOMDocument; use TheSeer\phpDox\DocBlock\Factory; +use TheSeer\phpDox\DocBlock\FactoryException; use TheSeer\phpDox\DocBlock\GenericParser; use TheSeer\phpDox\DocBlock\InlineProcessor; use TheSeer\phpDox\FactoryInterface; @@ -38,10 +39,11 @@ public function testAddParserFactory(): void { } /** - * @expectedException \TheSeer\phpDox\DocBlock\FactoryException * @covers \TheSeer\phpDox\DocBlock\Factory::addParserFactory */ public function testAddParserFactoryExpectingFactoryException(): void { + self::expectException(FactoryException::class); + $mock = $this->createMock(FactoryInterface::class); $this->factory->addParserFactory([], $mock); } @@ -56,10 +58,11 @@ public function testAddParserClass(): void { /** * @dataProvider addParserClassDataprovider - * @expectedException \TheSeer\phpDox\DocBlock\FactoryException * @covers \TheSeer\phpDox\DocBlock\Factory::addParserClass */ public function testAddParserClassExpectingFactoryException($annotation, $classname): void { + self::expectException(FactoryException::class); + $this->factory->addParserClass($annotation, $classname); }