diff --git a/tests/PHP81/Php81LanguageFeaturesTest.php b/tests/PHP81/Php81LanguageFeaturesTest.php index 26af5885f..52b9933ab 100644 --- a/tests/PHP81/Php81LanguageFeaturesTest.php +++ b/tests/PHP81/Php81LanguageFeaturesTest.php @@ -6,6 +6,7 @@ use Mockery; use Mockery\Adapter\Phpunit\MockeryTestCase; use ReturnTypeWillChange; +use RuntimeException; use Serializable; /** @@ -82,6 +83,15 @@ public function it_can_mock_a_class_with_an_intersection_argument_type_hint() $mock->foo($object); } + + /** @test */ + public function it_can_mock_a_class_with_a_never_returning_type_hint() + { + $mock = Mockery::mock(NeverReturningTypehintClass::class)->makePartial(); + + $this->expectException(RuntimeException::class); + $mock->throws(); + } } interface LoggerInterface @@ -135,6 +145,18 @@ public function getTimestamp(): float } } +class NeverReturningTypehintClass +{ + public function throws(): never + { + throw new RuntimeException('Never!'); + } + + public function exits(): never + { + exit; + } +} class IntersectionTypeHelperClass { }