You are here

public function LocaleTranslationTest::testSerializable in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/locale/tests/src/Kernel/LocaleTranslationTest.php \Drupal\Tests\locale\Kernel\LocaleTranslationTest::testSerializable()
  2. 9 core/modules/locale/tests/src/Kernel/LocaleTranslationTest.php \Drupal\Tests\locale\Kernel\LocaleTranslationTest::testSerializable()

Tests that \Drupal\locale\LocaleTranslation is serializable.

File

core/modules/locale/tests/src/Kernel/LocaleTranslationTest.php, line 24

Class

LocaleTranslationTest
@coversDefaultClass \Drupal\locale\LocaleTranslation @group locale

Namespace

Drupal\Tests\locale\Kernel

Code

public function testSerializable() {
  $translation = $this->container
    ->get('string_translator.locale.lookup');
  $this
    ->assertInstanceOf(LocaleTranslation::class, $translation);

  // Prove that serialization and deserialization works without errors.
  $this
    ->assertNotNull($translation);
  $unserialized = unserialize(serialize($translation));
  $this
    ->assertInstanceOf(LocaleTranslation::class, $unserialized);
}