Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Remove abstract test case #107

Merged
merged 1 commit into from
Dec 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ includes:
parameters:
ergebnis:
classesAllowedToBeExtended:
- Ergebnis\Classy\Test\Unit\Exception\AbstractTestCase
- InvalidArgumentException
- LogicException
- ParseError
Expand Down
53 changes: 0 additions & 53 deletions test/Unit/Exception/AbstractTestCase.php

This file was deleted.

9 changes: 8 additions & 1 deletion test/Unit/Exception/DirectoryDoesNotExistTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,28 @@
namespace Ergebnis\Classy\Test\Unit\Exception;

use Ergebnis\Classy\Exception\DirectoryDoesNotExist;
use Ergebnis\Classy\Exception\ExceptionInterface;
use Localheinz\Test\Util\Helper;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\Classy\Exception\DirectoryDoesNotExist
*/
final class DirectoryDoesNotExistTest extends AbstractTestCase
final class DirectoryDoesNotExistTest extends Framework\TestCase
{
use Helper;

public function testFromDirectoryReturnsException(): void
{
$directory = $this->faker()->sentence;

$exception = DirectoryDoesNotExist::fromDirectory($directory);

self::assertInstanceOf(DirectoryDoesNotExist::class, $exception);
self::assertInstanceOf(\InvalidArgumentException::class, $exception);
self::assertInstanceOf(ExceptionInterface::class, $exception);

$message = \sprintf(
'Directory "%s" does not exist.',
Expand Down
9 changes: 8 additions & 1 deletion test/Unit/Exception/MultipleDefinitionsFoundTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
namespace Ergebnis\Classy\Test\Unit\Exception;

use Ergebnis\Classy\Construct;
use Ergebnis\Classy\Exception\ExceptionInterface;
use Ergebnis\Classy\Exception\MultipleDefinitionsFound;
use Localheinz\Test\Util\Helper;
use PHPUnit\Framework;

/**
* @internal
Expand All @@ -23,8 +26,10 @@
*
* @uses \Ergebnis\Classy\Construct
*/
final class MultipleDefinitionsFoundTest extends AbstractTestCase
final class MultipleDefinitionsFoundTest extends Framework\TestCase
{
use Helper;

public function testFromConstructsReturnsException(): void
{
$name = 'Foo\\Bar\\Baz';
Expand All @@ -41,6 +46,8 @@ public function testFromConstructsReturnsException(): void
$exception = MultipleDefinitionsFound::fromConstructs($constructs);

self::assertInstanceOf(MultipleDefinitionsFound::class, $exception);
self::assertInstanceOf(\RuntimeException::class, $exception);
self::assertInstanceOf(ExceptionInterface::class, $exception);

$format = <<<'PHP'
Multiple definitions have been found for the following constructs:
Expand Down
14 changes: 9 additions & 5 deletions test/Unit/Exception/ParseErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@

namespace Ergebnis\Classy\Test\Unit\Exception;

use Ergebnis\Classy\Exception\ExceptionInterface;
use Ergebnis\Classy\Exception\ParseError;
use Localheinz\Test\Util\Helper;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\Classy\Exception\ParseError
*/
final class ParseErrorTest extends AbstractTestCase
final class ParseErrorTest extends Framework\TestCase
{
public function testExtendsParseError(): void
{
$this->assertClassExtends(\ParseError::class, ParseError::class);
}
use Helper;

public function testFromParseErrorReturnsException(): void
{
Expand All @@ -34,6 +34,8 @@ public function testFromParseErrorReturnsException(): void
$exception = ParseError::fromParseError($parseError);

self::assertInstanceOf(ParseError::class, $exception);
self::assertInstanceOf(\ParseError::class, $exception);
self::assertInstanceOf(ExceptionInterface::class, $exception);
self::assertSame($parseError->getMessage(), $exception->getMessage());
self::assertSame(0, $exception->getCode());
self::assertSame($parseError, $exception->getPrevious());
Expand All @@ -50,6 +52,8 @@ public function testFromFileNameAndParseErrorReturnsException(): void
);

self::assertInstanceOf(ParseError::class, $exception);
self::assertInstanceOf(\ParseError::class, $exception);
self::assertInstanceOf(ExceptionInterface::class, $exception);

$expectedMessage = \sprintf(
'A parse error occurred when parsing "%s": "%s".',
Expand Down
11 changes: 5 additions & 6 deletions test/Unit/Exception/ShouldNotHappenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,24 @@

namespace Ergebnis\Classy\Test\Unit\Exception;

use Ergebnis\Classy\Exception\ExceptionInterface;
use Ergebnis\Classy\Exception\ShouldNotHappen;
use PHPUnit\Framework;

/**
* @internal
*
* @covers \Ergebnis\Classy\Exception\ShouldNotHappen
*/
final class ShouldNotHappenTest extends AbstractTestCase
final class ShouldNotHappenTest extends Framework\TestCase
{
public function testExtendsLogicException(): void
{
$this->assertClassExtends(\LogicException::class, ShouldNotHappen::class);
}

public function testCreateReturnsException(): void
{
$exception = ShouldNotHappen::create();

self::assertInstanceOf(ShouldNotHappen::class, $exception);
self::assertInstanceOf(\LogicException::class, $exception);
self::assertInstanceOf(ExceptionInterface::class, $exception);
self::assertSame('This should not happen.', $exception->getMessage());
self::assertSame(0, $exception->getCode());
self::assertNull($exception->getPrevious());
Expand Down