diff options
Diffstat (limited to 'core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php')
-rw-r--r-- | core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php b/core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php index 0b243cc..b038fd0 100644 --- a/core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php +++ b/core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php @@ -7,6 +7,7 @@ namespace Drupal\Tests\Core\StringTranslation; +use Drupal\Component\Render\FormattableMarkup; use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Tests\UnitTestCase; @@ -85,4 +86,27 @@ class TranslatableMarkupTest extends UnitTestCase { $this->assertRegExp('/Exception thrown while calling __toString on a .*Mock_TranslatableMarkup_.* object in .*TranslatableMarkupTest.php on line [0-9]+: Yes you may./', $this->lastErrorMessage); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage $string ("foo") must be a string. + * + * @covers ::__construct + */ + public function testIsStringAssertion() { + $translation = $this->getStringTranslationStub(); + new TranslatableMarkup(new TranslatableMarkup('foo', [], [], $translation)); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage $string ("foo") must be a string. + * + * @covers ::__construct + */ + public function testIsStringAssertionWithFormattableMarkup() { + $translation = $this->getStringTranslationStub(); + $formattable_string = new FormattableMarkup('@bar', ['@bar' => 'foo']); + new TranslatableMarkup($formattable_string); + } + } |