Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
DummyWithEnumUnion example
public
function
testDenormalizeUnionOfEnums
(
)
{
$serializer
=
new
Serializer
(
[
new
BackedEnumNormalizer
(
)
,
new
ObjectNormalizer
(
classMetadataFactory:
new
ClassMetadataFactory
(
new
AnnotationLoader
(
)
)
,
propertyTypeExtractor:
new
PropertyInfoExtractor
(
[
]
,
[
new
ReflectionExtractor
(
)
]
)
,
)
,
]
)
;
$normalized
=
$serializer
->
normalize
(
new
DummyWithEnumUnion
(
EnumA::A
)
)
;
$this
->
assertEquals
(
new
DummyWithEnumUnion
(
EnumA::A
)
,
$serializer
->
denormalize
(
$normalized
, DummyWithEnumUnion::
class
)
)
;
$normalized
=
$serializer
->
normalize
(
new
DummyWithEnumUnion
(
EnumB::B
)
)
;
$this
->
assertEquals
(
new
DummyWithEnumUnion
(
EnumB::B
)
,
$serializer
->
denormalize
(
$normalized
, DummyWithEnumUnion::
class
)
)
;
}
}
class
AbstractObjectNormalizerDummy
extends
AbstractObjectNormalizer
{
public
function
getSupportedTypes
(
?string
$format
)
: array
{