Issue #3128389 by clayfreeman, jungle, cliddell, john.oltman, acbramley, larowlan: [backport] LocaleTranslation is not serializable
parent
db7ab7ef7a
commit
4821bf7980
|
@ -4,6 +4,7 @@ namespace Drupal\locale;
|
|||
|
||||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
|
||||
use Drupal\Core\DestructableInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
|
@ -19,6 +20,8 @@ use Symfony\Component\HttpFoundation\RequestStack;
|
|||
*/
|
||||
class LocaleTranslation implements TranslatorInterface, DestructableInterface {
|
||||
|
||||
use DependencySerializationTrait;
|
||||
|
||||
/**
|
||||
* Storage for strings.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\locale\Kernel;
|
||||
|
||||
use Drupal\locale\LocaleTranslation;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\locale\LocaleTranslation
|
||||
* @group locale
|
||||
*/
|
||||
class LocaleTranslationTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = [
|
||||
'locale',
|
||||
];
|
||||
|
||||
/**
|
||||
* Tests that \Drupal\locale\LocaleTranslation is serializable.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue