File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
lib/Doctrine/ODM/MongoDB/Mapping
tests/Doctrine/ODM/MongoDB/Tests/Mapping Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -2527,6 +2527,11 @@ public function __wakeup()
2527
2527
foreach ($ this ->fieldMappings as $ field => $ mapping ) {
2528
2528
$ prop = $ this ->reflectionService ->getAccessibleProperty ($ mapping ['declared ' ] ?? $ this ->name , $ field );
2529
2529
assert ($ prop instanceof ReflectionProperty);
2530
+
2531
+ if (isset ($ mapping ['enumType ' ])) {
2532
+ $ prop = new EnumReflectionProperty ($ prop , $ mapping ['enumType ' ]);
2533
+ }
2534
+
2530
2535
$ this ->reflFields [$ field ] = $ prop ;
2531
2536
}
2532
2537
}
Original file line number Diff line number Diff line change 13
13
use Doctrine \ODM \MongoDB \Tests \ClassMetadataTestUtil ;
14
14
use Doctrine \ODM \MongoDB \Types \Type ;
15
15
use Doctrine \ODM \MongoDB \Utility \CollectionHelper ;
16
+ use Doctrine \Persistence \Reflection \EnumReflectionProperty ;
16
17
use DoctrineGlobal_Article ;
17
18
use DoctrineGlobal_User ;
18
19
use Documents \Account ;
@@ -207,6 +208,22 @@ public function testEnumTypeFromReflection(): void
207
208
self ::assertFalse ($ cm ->isNullable ('nullableSuit ' ));
208
209
}
209
210
211
+ /**
212
+ * @requires PHP >= 8.1
213
+ */
214
+ public function testEnumReflectionPropertySerialization (): void
215
+ {
216
+ $ cm = new ClassMetadata (Card::class);
217
+
218
+ $ cm ->mapField (['fieldName ' => 'suit ' ]);
219
+ self ::assertInstanceOf (EnumReflectionProperty::class, $ cm ->reflFields ['suit ' ]);
220
+
221
+ $ serialized = serialize ($ cm );
222
+ $ cm = unserialize ($ serialized );
223
+
224
+ self ::assertInstanceOf (EnumReflectionProperty::class, $ cm ->reflFields ['suit ' ]);
225
+ }
226
+
210
227
/**
211
228
* @requires PHP >= 8.1
212
229
*/
You can’t perform that action at this time.
0 commit comments