function ValidationResultTest::testMessagesMustBeTranslatable

Tests that the messages are asserted to be translatable.

@testWith ["createError"]
["createWarning"]

File

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

Class

ValidationResultTest
@coversDefaultClass \Drupal\package_manager\ValidationResult[[api-linebreak]] @group package_manager @internal

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.