function TranslatableMarkupTest::testIsStringAssertionWithFormattableMarkup

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php \Drupal\Tests\Core\StringTranslation\TranslatableMarkupTest::testIsStringAssertionWithFormattableMarkup()
  2. 10 core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php \Drupal\Tests\Core\StringTranslation\TranslatableMarkupTest::testIsStringAssertionWithFormattableMarkup()
  3. 11.x core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php \Drupal\Tests\Core\StringTranslation\TranslatableMarkupTest::testIsStringAssertionWithFormattableMarkup()

@covers ::__construct

File

core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php, line 97

Class

TranslatableMarkupTest
Tests the TranslatableMarkup class.

Namespace

Drupal\Tests\Core\StringTranslation

Code

public function testIsStringAssertionWithFormattableMarkup() {
    $formattable_string = new FormattableMarkup('@bar', [
        '@bar' => 'foo',
    ]);
    $this->expectException(\InvalidArgumentException::class);
    $this->expectExceptionMessage('$string ("foo") must be a string.');
    new TranslatableMarkup($formattable_string);
}

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