Loading core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php +22 −5 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ use Drupal\Core\Entity\EntityType; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Core\StringTranslation\TranslationManager; use Drupal\Tests\UnitTestCase; /** Loading Loading @@ -515,10 +515,7 @@ public function testIsSubClassOf() { 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 = new UnserializableTranslationManager(); $translation_service->_serviceId = 'string_translation'; $entity_type->setStringTranslation($translation_service); Loading @@ -528,3 +525,23 @@ public function testIsSerializable() { } } /** * Test class. */ class UnserializableTranslationManager extends TranslationManager { /** * Constructs a UnserializableTranslationManager object. */ public function __construct() { } /** * @return array */ public function __serialize(): array { throw new \Exception(); } } core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php +16 −5 Original line number Diff line number Diff line Loading @@ -355,12 +355,9 @@ public function testDeleteIfOwner() { */ public function testSerialization() { // Add an unserializable request to the request stack. If the tempstore // didn't use DependencySerializationTrait, the exception would be thrown // didn't use DependencySerializationTrait, an exception would be thrown // when we try to serialize the tempstore. $request = $this->prophesize(Request::class); $request->willImplement('\Serializable'); $request->serialize()->willThrow(new \LogicException('Oops!')); $unserializable_request = $request->reveal(); $unserializable_request = new UnserializableRequest(); $this->requestStack->push($unserializable_request); $this->requestStack->_serviceId = 'request_stack'; Loading Loading @@ -427,3 +424,17 @@ public function testLegacyFactoryConstructor() { } } /** * A class for testing. */ class UnserializableRequest extends Request { /** * @return array */ public function __serialize(): array { throw new \LogicException('Oops!'); } } Loading
core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php +22 −5 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ use Drupal\Core\Entity\EntityType; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\Core\StringTranslation\TranslationManager; use Drupal\Tests\UnitTestCase; /** Loading Loading @@ -515,10 +515,7 @@ public function testIsSubClassOf() { 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 = new UnserializableTranslationManager(); $translation_service->_serviceId = 'string_translation'; $entity_type->setStringTranslation($translation_service); Loading @@ -528,3 +525,23 @@ public function testIsSerializable() { } } /** * Test class. */ class UnserializableTranslationManager extends TranslationManager { /** * Constructs a UnserializableTranslationManager object. */ public function __construct() { } /** * @return array */ public function __serialize(): array { throw new \Exception(); } }
core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php +16 −5 Original line number Diff line number Diff line Loading @@ -355,12 +355,9 @@ public function testDeleteIfOwner() { */ public function testSerialization() { // Add an unserializable request to the request stack. If the tempstore // didn't use DependencySerializationTrait, the exception would be thrown // didn't use DependencySerializationTrait, an exception would be thrown // when we try to serialize the tempstore. $request = $this->prophesize(Request::class); $request->willImplement('\Serializable'); $request->serialize()->willThrow(new \LogicException('Oops!')); $unserializable_request = $request->reveal(); $unserializable_request = new UnserializableRequest(); $this->requestStack->push($unserializable_request); $this->requestStack->_serviceId = 'request_stack'; Loading Loading @@ -427,3 +424,17 @@ public function testLegacyFactoryConstructor() { } } /** * A class for testing. */ class UnserializableRequest extends Request { /** * @return array */ public function __serialize(): array { throw new \LogicException('Oops!'); } }