PluralTranslatableMarkupTest.php in Drupal 10
File
core/tests/Drupal/Tests/Core/StringTranslation/PluralTranslatableMarkupTest.php
View source
<?php
namespace Drupal\Tests\Core\StringTranslation;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
use Drupal\Tests\UnitTestCase;
class PluralTranslatableMarkupTest extends UnitTestCase {
public function testPluralTranslatableMarkupSerialization($count, $expected_text) {
$container = new ContainerBuilder();
$container
->set('string_translation', $this
->getStringTranslationStub());
\Drupal::setContainer($container);
$markup = new PluralTranslatableMarkup($count, 'singular @count', 'plural @count');
$serialized_markup = unserialize(serialize($markup));
$this
->assertEquals($expected_text, $serialized_markup
->render());
}
public function providerPluralTranslatableMarkupSerialization() {
return [
[
1,
'singular 1',
],
[
2,
'plural 2',
],
];
}
}