function PhpUnitWarningsTest::testExpectExceptionMessageRegExp

Tests expectExceptionMessageRegExp.

File

core/tests/Drupal/Tests/PhpUnitWarningsTest.php, line 112

Class

PhpUnitWarningsTest
@coversDefaultClass \Drupal\Tests\Traits\PhpUnitWarnings @group legacy

Namespace

Drupal\Tests

Code

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');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.