From dd8c7003b87bcefc9097c31572784832b1c881bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 6 Oct 2022 08:44:01 +0200 Subject: [PATCH] Assert that serialization leaves PersistentCollection usable That feature is no longer covered since support for merging entities in the entity manager was removed. --- tests/Doctrine/Tests/ORM/PersistentCollectionTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php index faaa05b9ff0..704799c9e34 100644 --- a/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php +++ b/tests/Doctrine/Tests/ORM/PersistentCollectionTest.php @@ -21,6 +21,8 @@ use function array_keys; use function assert; use function method_exists; +use function serialize; +use function unserialize; /** * Tests the lazy-loading capabilities of the PersistentCollection and the initialization of collections. @@ -286,4 +288,13 @@ public function testModifyUOWForDeferredImplicitOwnerOnClear(): void $this->collection->clear(); } + + public function testItCanBeSerializedAndUnserializedBack(): void + { + $this->collection->add(new stdClass()); + $collection = unserialize(serialize($this->collection)); + $collection->add(new stdClass()); + $collection[3] = new stdClass(); + self::assertCount(3, $collection); + } }