Created
August 25, 2023 03:14
-
-
Save ghostwriter/7a45ffbba8ac2746175a4e82a5d22d79 to your computer and use it in GitHub Desktop.
#PHPUnit `expect*()` replacement.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace Foo\Tests\Unit; | |
final class FooTest extends TestCase | |
{ | |
public function testFoo(): void | |
{ | |
set_error_handler( | |
static function (int $errno, string $errstr ) { | |
restore_error_handler(); | |
throw new \Exception( $errstr, $errno ); | |
}, | |
E_ALL | |
); | |
$this->expectException(\Exception::class); | |
$this->expectExceptionMessageMatches('Expected Warning/Error/Deprecation message'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment