FormattableMarkupTest.php in Zircon Profile 8
File
core/tests/Drupal/Tests/Component/Render/FormattableMarkupTest.php
View source
<?php
namespace Drupal\Tests\Component\Render;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Tests\UnitTestCase;
class FormattableMarkupTest extends UnitTestCase {
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);
}
public function testCount() {
$string = 'Can I please have a @replacement';
$formattable_string = new FormattableMarkup($string, [
'@replacement' => 'kitten',
]);
$this
->assertEquals(strlen($string), $formattable_string
->count());
}
}