X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Ftests%2FDrupal%2FTests%2FCore%2FEntity%2FEntityTypeTest.php;fp=web%2Fcore%2Ftests%2FDrupal%2FTests%2FCore%2FEntity%2FEntityTypeTest.php;h=4027647abfd267ce691a6e16c47011f0908bb546;hp=b28a72c617f7bf97e519955744e4d398fe31549d;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php b/web/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php index b28a72c61..4027647ab 100644 --- a/web/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php +++ b/web/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\Core\Entity; use Drupal\Core\Entity\EntityType; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; +use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Tests\UnitTestCase; /** @@ -476,4 +477,22 @@ class EntityTypeTest extends UnitTestCase { $this->assertEmpty($reflection->getProperties(\ReflectionProperty::IS_PUBLIC)); } + /** + * Tests that the EntityType object can be serialized. + */ + 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()); + } + }