function TranslatableMarkupTest::testToString
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php \Drupal\Tests\Core\StringTranslation\TranslatableMarkupTest::testToString()
- 10 core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php \Drupal\Tests\Core\StringTranslation\TranslatableMarkupTest::testToString()
- 9 core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php \Drupal\Tests\Core\StringTranslation\TranslatableMarkupTest::testToString()
- 8.9.x core/tests/Drupal/Tests/Core/StringTranslation/TranslatableMarkupTest.php \Drupal\Tests\Core\StringTranslation\TranslatableMarkupTest::testToString()
Tests that errors are correctly handled when a __toString() fails.
@legacy-covers ::__toString
File
-
core/
tests/ Drupal/ Tests/ Core/ StringTranslation/ TranslatableMarkupTest.php, line 25
Class
- TranslatableMarkupTest
- Tests the TranslatableMarkup class.
Namespace
Drupal\Tests\Core\StringTranslationCode
public function testToString() : void {
$string = 'May I have an exception?';
$exception = new \Exception('Yes you may.');
$text = $this->getMockBuilder(TranslatableMarkup::class)
->setConstructorArgs([
$string,
[],
[],
])
->onlyMethods([
'render',
])
->getMock();
$text->expects($this->once())
->method('render')
->willThrowException($exception);
$this->expectException(\Exception::class);
$this->expectExceptionMessage($exception->getMessage());
(string) $text;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.