Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setSymfony example
return
new
GetSetMethodNormalizer
(
$classMetadataFactory
)
;
}
public
function
testGroupsNormalizeWithNameConverter
(
)
{
$classMetadataFactory
=
new
ClassMetadataFactory
(
new
AnnotationLoader
(
)
)
;
$this
->normalizer =
new
GetSetMethodNormalizer
(
$classMetadataFactory
,
new
CamelCaseToSnakeCaseNameConverter
(
)
)
;
$this
->normalizer->
setSerializer
(
$this
->serializer
)
;
$obj
=
new
GroupDummy
(
)
;
$obj
->
setFooBar
(
'@dunglas'
)
;
$obj
->
setSymfony
(
'@coopTilleuls'
)
;
$obj
->
setCoopTilleuls
(
'les-tilleuls.coop'
)
;
$this
->
assertEquals
(
[
'bar' => null,
'foo_bar' => '@dunglas',
'symfony' => '@coopTilleuls',
]
,
$this
->normalizer->
normalize
(
$obj
, null,
[
GetSetMethodNormalizer::GROUPS =>
[
'name_converter'
]
]
)
)
;
}
abstract
protected
function
getDenormalizerForGroups
(
)
: DenormalizerInterface;
public
function
testGroupsNormalize
(
)
{
$normalizer
=
$this
->
getNormalizerForGroups
(
)
;
$obj
=
new
GroupDummy
(
)
;
$obj
->
setFoo
(
'foo'
)
;
$obj
->
setBar
(
'bar'
)
;
$obj
->
setFooBar
(
'fooBar'
)
;
$obj
->
setSymfony
(
'symfony'
)
;
$obj
->
setKevin
(
'kevin'
)
;
$obj
->
setCoopTilleuls
(
'coopTilleuls'
)
;
$this
->
assertEquals
(
[
'bar' => 'bar',
]
,
$normalizer
->
normalize
(
$obj
, null,
[
'groups' =>
[
'c'
]
]
)
)
;
$this
->
assertEquals
(
[
'symfony' => 'symfony',
'foo' => 'foo',
'fooBar' => 'fooBar',
return
new
ObjectNormalizer
(
$classMetadataFactory
)
;
}
public
function
testGroupsNormalizeWithNameConverter
(
)
{
$classMetadataFactory
=
new
ClassMetadataFactory
(
new
AnnotationLoader
(
)
)
;
$this
->normalizer =
new
ObjectNormalizer
(
$classMetadataFactory
,
new
CamelCaseToSnakeCaseNameConverter
(
)
)
;
$this
->normalizer->
setSerializer
(
$this
->serializer
)
;
$obj
=
new
GroupDummy
(
)
;
$obj
->
setFooBar
(
'@dunglas'
)
;
$obj
->
setSymfony
(
'@coopTilleuls'
)
;
$obj
->
setCoopTilleuls
(
'les-tilleuls.coop'
)
;
$this
->
assertEquals
(
[
'bar' => null,
'foo_bar' => '@dunglas',
'symfony' => '@coopTilleuls',
]
,
$this
->normalizer->
normalize
(
$obj
, null,
[
ObjectNormalizer::GROUPS =>
[
'name_converter'
]
]
)
)
;
}
return
new
PropertyNormalizer
(
$classMetadataFactory
)
;
}
public
function
testGroupsNormalizeWithNameConverter
(
)
{
$classMetadataFactory
=
new
ClassMetadataFactory
(
new
AnnotationLoader
(
)
)
;
$this
->normalizer =
new
PropertyNormalizer
(
$classMetadataFactory
,
new
CamelCaseToSnakeCaseNameConverter
(
)
)
;
$this
->normalizer->
setSerializer
(
$this
->serializer
)
;
$obj
=
new
GroupDummy
(
)
;
$obj
->
setFooBar
(
'@dunglas'
)
;
$obj
->
setSymfony
(
'@coopTilleuls'
)
;
$obj
->
setCoopTilleuls
(
'les-tilleuls.coop'
)
;
$this
->
assertEquals
(
[
'bar' => null,
'foo_bar' => '@dunglas',
'symfony' => '@coopTilleuls',
]
,
$this
->normalizer->
normalize
(
$obj
, null,
[
PropertyNormalizer::GROUPS =>
[
'name_converter'
]
]
)
)
;
}