public function FormattableMarkupTest::testToString in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php \Drupal\Tests\Component\Render\FormattableMarkupTest::testToString()
 - 9 core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php \Drupal\Tests\Component\Render\FormattableMarkupTest::testToString()
 
@covers ::__toString @covers ::jsonSerialize
File
- core/
tests/ Drupal/ Tests/ Component/ Render/ FormattableMarkupTest.php, line 37  
Class
- FormattableMarkupTest
 - Tests the TranslatableMarkup class.
 
Namespace
Drupal\Tests\Component\RenderCode
public function testToString() {
  $string = 'Can I please have a @replacement';
  $formattable_string = new FormattableMarkup($string, [
    '@replacement' => 'kitten',
  ]);
  $text = (string) $formattable_string;
  $this
    ->assertEquals('Can I please have a kitten', $text);
  $text = $formattable_string
    ->jsonSerialize();
  $this
    ->assertEquals('Can I please have a kitten', $text);
}