You are here

public function PluralTranslatableMarkupTest::testPluralTranslatableMarkupSerialization in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/StringTranslation/PluralTranslatableMarkupTest.php \Drupal\Tests\Core\StringTranslation\PluralTranslatableMarkupTest::testPluralTranslatableMarkupSerialization()
  2. 10 core/tests/Drupal/Tests/Core/StringTranslation/PluralTranslatableMarkupTest.php \Drupal\Tests\Core\StringTranslation\PluralTranslatableMarkupTest::testPluralTranslatableMarkupSerialization()

Tests serialization of PluralTranslatableMarkup().

@dataProvider providerPluralTranslatableMarkupSerialization

File

core/tests/Drupal/Tests/Core/StringTranslation/PluralTranslatableMarkupTest.php, line 22

Class

PluralTranslatableMarkupTest
Tests the TranslatableMarkup class.

Namespace

Drupal\Tests\Core\StringTranslation

Code

public function testPluralTranslatableMarkupSerialization($count, $expected_text) {

  // Add a mock string translation service to the container.
  $container = new ContainerBuilder();
  $container
    ->set('string_translation', $this
    ->getStringTranslationStub());
  \Drupal::setContainer($container);

  // Create an object to serialize and unserialize.
  $markup = new PluralTranslatableMarkup($count, 'singular @count', 'plural @count');
  $serialized_markup = unserialize(serialize($markup));
  $this
    ->assertEquals($expected_text, $serialized_markup
    ->render());
}