Skip to content

Commit

Permalink
Test never-returning function/method that throws an exception
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
  • Loading branch information
ghostwriter committed Jun 8, 2022
1 parent e575d2b commit 705f675
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/PHP81/Php81LanguageFeaturesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Mockery;
use Mockery\Adapter\Phpunit\MockeryTestCase;
use ReturnTypeWillChange;
use RuntimeException;
use Serializable;

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
{
}
Expand Down

0 comments on commit 705f675

Please sign in to comment.