Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
UidNormalizer example
$extractor
=
new
PropertyInfoExtractor
(
[
]
,
[
new
PhpDocExtractor
(
)
,
new
ReflectionExtractor
(
)
]
)
;
$serializer
=
new
Serializer
(
[
new
ArrayDenormalizer
(
)
,
new
DateTimeNormalizer
(
)
,
new
DateTimeZoneNormalizer
(
)
,
new
DataUriNormalizer
(
)
,
new
UidNormalizer
(
)
,
new
ObjectNormalizer
(
$classMetadataFactory
, null, null,
$extractor
,
$classMetadataFactory
?
new
ClassDiscriminatorFromClassMetadata
(
$classMetadataFactory
)
: null
)
,
]
,
[
'json' =>
new
JsonEncoder
(
)
]
)
;
try
{
$serializer
->
deserialize
(
$json
, Php74Full::
class
, 'json',
[
DenormalizerInterface::COLLECT_DENORMALIZATION_ERRORS => true,
]
)
;
$this
->
fail
(
)
;
}
use
Symfony\Component\Uid\UuidV5;
use
Symfony\Component\Uid\UuidV6;
class
UidNormalizerTest
extends
TestCase
{
use
ExpectDeprecationTrait;
private
UidNormalizer
$normalizer
;
protected
function
setUp
(
)
: void
{
$this
->normalizer =
new
UidNormalizer
(
)
;
}
public
function
testSupportsNormalization
(
)
{
$this
->
assertTrue
(
$this
->normalizer->
supportsNormalization
(
Uuid::
v1
(
)
)
)
;
$this
->
assertTrue
(
$this
->normalizer->
supportsNormalization
(
Uuid::
v3
(
Uuid::
v1
(
)
, 'foo'
)
)
)
;
$this
->
assertTrue
(
$this
->normalizer->
supportsNormalization
(
Uuid::
v4
(
)
)
)
;
$this
->
assertTrue
(
$this
->normalizer->
supportsNormalization
(
Uuid::
v5
(
Uuid::
v1
(
)
, 'foo'
)
)
)
;
$this
->
assertTrue
(
$this
->normalizer->
supportsNormalization
(
Uuid::
v6
(
)
)
)
;
$this
->
assertTrue
(
$this
->normalizer->
supportsNormalization
(
new
Ulid
(
)
)
)
;
$this
->
assertFalse
(
$this
->normalizer->
supportsNormalization
(
new
\
stdClass
(
)
)
)
;
}