function EntityTypeTest::testIsSerializable
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityTypeTest.php \Drupal\KernelTests\Core\Entity\EntityTypeTest::testIsSerializable()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityTypeTest.php \Drupal\KernelTests\Core\Entity\EntityTypeTest::testIsSerializable()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityTypeTest.php \Drupal\KernelTests\Core\Entity\EntityTypeTest::testIsSerializable()
Tests that the EntityType object can be serialized.
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityTypeTest.php, line 515
Class
- EntityTypeTest
- @coversDefaultClass \Drupal\Core\Entity\EntityType @group Entity
Namespace
Drupal\Tests\Core\EntityCode
public function testIsSerializable() {
$entity_type = $this->setUpEntityType([]);
$translation = $this->prophesize(TranslationInterface::class);
$translation->willImplement(\Serializable::class);
$translation->serialize()
->willThrow(\Exception::class);
$translation_service = $translation->reveal();
$translation_service->_serviceId = 'string_translation';
$entity_type->setStringTranslation($translation_service);
$entity_type = unserialize(serialize($entity_type));
$this->assertEquals('example_entity_type', $entity_type->id());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.