Skip to content

Commit

Permalink
Closes #4490
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Oct 25, 2020
1 parent 068e79c commit b29ed05
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ChangeLog-9.5.md
Expand Up @@ -4,4 +4,8 @@ All notable changes of the PHPUnit 9.5 release series are documented in this fil

## [9.5.0] - 2020-12-04

### Changed

* [#4490](https://github.com/sebastianbergmann/phpunit/issues/4490): Emit Error instead of Warning when test case class cannot be instantiated

[9.5.0]: https://github.com/sebastianbergmann/phpunit/compare/9.4...master
2 changes: 1 addition & 1 deletion src/Framework/TestBuilder.php
Expand Up @@ -30,7 +30,7 @@ public function build(ReflectionClass $theClass, string $methodName): Test
$className = $theClass->getName();

if (!$theClass->isInstantiable()) {
return new WarningTestCase(
return new ErrorTestCase(
sprintf('Cannot instantiate class "%s".', $className)
);
}
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/Framework/TestBuilderTest.php
Expand Up @@ -66,8 +66,10 @@ public function testCreateTestForNotInstantiableTestClass(): void
->willReturn('foo');

$test = (new TestBuilder)->build($reflector, 'TestForNonInstantiableTestClass');
$this->assertInstanceOf(WarningTestCase::class, $test);
/* @var WarningTestCase $test */

$this->assertInstanceOf(ErrorTestCase::class, $test);

/* @var ErrorTestCase $test */
$this->assertSame('Cannot instantiate class "foo".', $test->getMessage());
}

Expand Down

0 comments on commit b29ed05

Please sign in to comment.