function ValidationResultTest::testMessagesMustBeTranslatable

Tests that the messages are asserted to be translatable.

Attributes

#[TestWith([ "createError", ])] #[TestWith([ "createWarning", ])]

File

core/modules/package_manager/tests/src/Unit/ValidationResultTest.php, line 114

Class

ValidationResultTest
Tests Drupal\package_manager\ValidationResult.

Namespace

Drupal\Tests\package_manager\Unit

Code

public function testMessagesMustBeTranslatable(string $method) : void {
  // When creating an error from a throwable, the message does not need to be
  // translatable.
  ValidationResult::createErrorFromThrowable(new \Exception('Burn it down.'));
  $this->expectException(\AssertionError::class);
  $this->expectExceptionMessageMatches('/instanceof TranslatableMarkup/');
  ValidationResult::$method([
    'Not translatable!',
  ]);
}

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