Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Entity / EntityTypeTest.php
index b28a72c617f7bf97e519955744e4d398fe31549d..4027647abfd267ce691a6e16c47011f0908bb546 100644 (file)
@@ -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());
+  }
+
 }