Skip to content

Commit

Permalink
Fix PHPUnit 9 compatibility for expectedException.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyril VERLOOP authored and theseer committed Oct 12, 2019
1 parent ed98080 commit 3945e2d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
9 changes: 5 additions & 4 deletions tests/Unit/DirectoryCleanerTest.php
@@ -1,6 +1,8 @@
<?php declare(strict_types = 1);
namespace TheSeer\phpDox;

use TheSeer\phpDox\DirectoryCleanerException;

class DirectoryCleanerTest extends \PHPUnit\Framework\TestCase {
/**
* @var DirectoryCleaner
Expand All @@ -11,11 +13,10 @@ protected function setUp(): void {
$this->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'));
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/config/GlobalConfigTest.php
Expand Up @@ -2,6 +2,7 @@
namespace TheSeer\phpDox;

use TheSeer\fDOM\fDOMDocument;
use TheSeer\phpDox\ConfigException;

/**
* Class GlobalConfigTest
Expand Down Expand Up @@ -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');
}

Expand Down
4 changes: 3 additions & 1 deletion tests/Unit/docblock/DocBlockTest.php
Expand Up @@ -3,6 +3,7 @@

use PHPUnit\Framework\TestCase;
use TheSeer\fDOM\fDOMDocument;
use TheSeer\phpDox\DocBlock\DocBlockException;

/**
* Class DocBlockTest
Expand Down Expand Up @@ -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');
}

Expand Down
7 changes: 5 additions & 2 deletions tests/Unit/docblock/FactoryTest.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}

Expand Down

0 comments on commit 3945e2d

Please sign in to comment.