Skip to content

Commit 2c7d612

Browse files
committed
minor #52728 [Serializer] fix tests (xabbuh)
This PR was merged into the 6.4 branch. Discussion ---------- [Serializer] fix tests | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT Commits ------- 67969da fix tests
2 parents 7096a1e + 67969da commit 2c7d612

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

src/Symfony/Component/Serializer/Tests/Normalizer/AbstractObjectNormalizerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -837,12 +837,12 @@ public function testDenormalizeWithCorrectOrderOfAttributeAndProperty()
837837
$this->assertSame('nested-id', $test->id);
838838
}
839839

840-
public function testNormalizeWithIgnoreAnnotationAndPrivateProperties()
840+
public function testNormalizeWithIgnoreAttributeAndPrivateProperties()
841841
{
842-
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
842+
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
843843
$serializer = new Serializer([new ObjectNormalizer($classMetadataFactory)]);
844844

845-
$this->assertSame(['foo' => 'foo'], $serializer->normalize(new ObjectDummyWithIgnoreAnnotationAndPrivateProperty()));
845+
$this->assertSame(['foo' => 'foo'], $serializer->normalize(new ObjectDummyWithIgnoreAttributeAndPrivateProperty()));
846846
}
847847

848848
public function testDenormalizeUntypedFormat()
@@ -1054,11 +1054,11 @@ class ObjectDummyWithContextAttributeSkipNullValues
10541054
public ?string $propertyWithNullSkipNullValues = null;
10551055
}
10561056

1057-
class ObjectDummyWithIgnoreAnnotationAndPrivateProperty
1057+
class ObjectDummyWithIgnoreAttributeAndPrivateProperty
10581058
{
10591059
public $foo = 'foo';
10601060

1061-
/** @Ignore */
1061+
#[Ignore]
10621062
public $ignored = 'ignored';
10631063

10641064
private $private = 'private';

src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
1717
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
1818
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
19-
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
19+
use Symfony\Component\Serializer\Attribute\DiscriminatorMap;
2020
use Symfony\Component\Serializer\Exception\LogicException;
2121
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
2222
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
@@ -494,7 +494,7 @@ protected function getNormalizerForSkipUninitializedValues(): NormalizerInterfac
494494

495495
public function testNormalizeWithDiscriminator()
496496
{
497-
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
497+
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
498498
$discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
499499
$normalizer = new GetSetMethodNormalizer($classMetadataFactory, null, null, $discriminator);
500500

@@ -503,7 +503,7 @@ public function testNormalizeWithDiscriminator()
503503

504504
public function testDenormalizeWithDiscriminator()
505505
{
506-
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
506+
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
507507
$discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
508508
$normalizer = new GetSetMethodNormalizer($classMetadataFactory, null, null, $discriminator);
509509

@@ -777,12 +777,10 @@ public function __call($key, $value)
777777
}
778778
}
779779

780-
/**
781-
* @DiscriminatorMap(typeProperty="type", mapping={
782-
* "one" = GetSetMethodDiscriminatedDummyOne::class,
783-
* "two" = GetSetMethodDiscriminatedDummyTwo::class,
784-
* })
785-
*/
780+
#[DiscriminatorMap(typeProperty: 'type', mapping: [
781+
'one' => GetSetMethodDiscriminatedDummyOne::class,
782+
'two' => GetSetMethodDiscriminatedDummyTwo::class,
783+
])]
786784
interface GetSetMethodDummyInterface
787785
{
788786
}

src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
1616
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
1717
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
18-
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
18+
use Symfony\Component\Serializer\Attribute\DiscriminatorMap;
1919
use Symfony\Component\Serializer\Exception\LogicException;
2020
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
2121
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
@@ -499,7 +499,7 @@ protected function getNormalizerForSkipUninitializedValues(): NormalizerInterfac
499499

500500
public function testNormalizeWithDiscriminator()
501501
{
502-
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
502+
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
503503
$discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
504504
$normalizer = new PropertyNormalizer($classMetadataFactory, null, null, $discriminator);
505505

@@ -508,7 +508,7 @@ public function testNormalizeWithDiscriminator()
508508

509509
public function testDenormalizeWithDiscriminator()
510510
{
511-
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
511+
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
512512
$discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
513513
$normalizer = new PropertyNormalizer($classMetadataFactory, null, null, $discriminator);
514514

@@ -621,12 +621,10 @@ public function getIntMatrix(): array
621621
}
622622
}
623623

624-
/**
625-
* @DiscriminatorMap(typeProperty="type", mapping={
626-
* "one" = PropertyDiscriminatedDummyOne::class,
627-
* "two" = PropertyDiscriminatedDummyTwo::class,
628-
* })
629-
*/
624+
#[DiscriminatorMap(typeProperty: 'type', mapping: [
625+
'one' => PropertyDiscriminatedDummyOne::class,
626+
'two' => PropertyDiscriminatedDummyTwo::class,
627+
])]
630628
interface PropertyDummyInterface
631629
{
632630
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy