function FailureMarkerTest::testGetMessageWithThrowable

Tests get message with throwable.

@legacy-covers ::getMessage

Attributes

#[TestWith([ TRUE, ])] #[TestWith([ FALSE, ])]

File

core/modules/package_manager/tests/src/Kernel/FailureMarkerTest.php, line 49

Class

FailureMarkerTest
Tests Drupal\package_manager\FailureMarker.

Namespace

Drupal\Tests\package_manager\Kernel

Code

public function testGetMessageWithThrowable(bool $include_backtrace) : void {
  $failure_marker = $this->container
    ->get(FailureMarker::class);
  $failure_marker->write($this->createStage(), $this->t('Disastrous catastrophe!'), new \Exception('Witchcraft!'));
  $expected_pattern = $include_backtrace ? <<<REGEXP
  /^Disastrous catastrophe! Caused by Exception, with this message: Witchcraft!
  Backtrace:
  #0 .*FailureMarkerTest->testGetMessageWithThrowable\\(true\\)
  #1 .*
  #2 .*
  #3 .*/
  REGEXP : '/^Disastrous catastrophe! Caused by Exception, with this message: Witchcraft!$/';
  $this->assertMatchesRegularExpression($expected_pattern, $failure_marker->getMessage($include_backtrace));
}

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