public function PhpUnitWarningsTest::testExpectExceptionMessageRegExp in Drupal 9
Tests expectExceptionMessageRegExp.
File
- core/
tests/ Drupal/ Tests/ PhpUnitWarningsTest.php, line 112
Class
- PhpUnitWarningsTest
- @coversDefaultClass \Drupal\Tests\Traits\PhpUnitWarnings @group legacy
Namespace
Drupal\TestsCode
public function testExpectExceptionMessageRegExp() {
if (RunnerVersion::getMajor() > 8) {
$this
->markTestSkipped("In PHPUnit 9+, expectExceptionMessageRegExp() is removed.");
}
$this
->expectDeprecation('expectExceptionMessageRegExp() is deprecated in PHPUnit 8 and will be removed in PHPUnit 9. Use expectExceptionMessageMatches() instead.');
$this
->expectException(\Exception::class);
$this
->expectExceptionMessageRegExp('/An exception .*/');
throw new \Exception('An exception has been triggered');
}