function FormattableMarkupTest::testUnexpectedPlaceholder
Same name in other branches
- 9 core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php \Drupal\Tests\Component\Render\FormattableMarkupTest::testUnexpectedPlaceholder()
- 8.9.x core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php \Drupal\Tests\Component\Render\FormattableMarkupTest::testUnexpectedPlaceholder()
- 10 core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php \Drupal\Tests\Component\Render\FormattableMarkupTest::testUnexpectedPlaceholder()
@covers ::__toString @dataProvider providerTestUnexpectedPlaceholder
File
-
core/
tests/ Drupal/ Tests/ Component/ Render/ FormattableMarkupTest.php, line 78
Class
- FormattableMarkupTest
- Tests the TranslatableMarkup class.
Namespace
Drupal\Tests\Component\RenderCode
public function testUnexpectedPlaceholder($string, $arguments, $error_number, $error_message) : void {
// We set a custom error handler because of https://github.com/sebastianbergmann/phpunit/issues/487
set_error_handler([
$this,
'errorHandler',
]);
// We want this to trigger an error.
$markup = new FormattableMarkup($string, $arguments);
// Cast it to a string which will generate the errors.
$output = (string) $markup;
restore_error_handler();
// The string should not change.
$this->assertEquals($string, $output);
$this->assertEquals($error_number, $this->lastErrorNumber);
$this->assertEquals($error_message, $this->lastErrorMessage);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.