diff --git a/ChangeLog-9.5.md b/ChangeLog-9.5.md index 263d9023e04..2646df236a3 100644 --- a/ChangeLog-9.5.md +++ b/ChangeLog-9.5.md @@ -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 diff --git a/src/Framework/TestBuilder.php b/src/Framework/TestBuilder.php index 583a9f2c485..92a57d02f8d 100644 --- a/src/Framework/TestBuilder.php +++ b/src/Framework/TestBuilder.php @@ -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) ); } diff --git a/tests/unit/Framework/TestBuilderTest.php b/tests/unit/Framework/TestBuilderTest.php index ae962074555..c3846c9d0da 100644 --- a/tests/unit/Framework/TestBuilderTest.php +++ b/tests/unit/Framework/TestBuilderTest.php @@ -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()); }