Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Nov 25, 2023
1 parent 3a92aac commit ff423e8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
10 changes: 5 additions & 5 deletions Tests/Normalizer/AbstractObjectNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -837,12 +837,12 @@ public function testDenormalizeWithCorrectOrderOfAttributeAndProperty()
$this->assertSame('nested-id', $test->id);
}

public function testNormalizeWithIgnoreAnnotationAndPrivateProperties()
public function testNormalizeWithIgnoreAttributeAndPrivateProperties()
{
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
$serializer = new Serializer([new ObjectNormalizer($classMetadataFactory)]);

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

public function testDenormalizeUntypedFormat()
Expand Down Expand Up @@ -1054,11 +1054,11 @@ class ObjectDummyWithContextAttributeSkipNullValues
public ?string $propertyWithNullSkipNullValues = null;
}

class ObjectDummyWithIgnoreAnnotationAndPrivateProperty
class ObjectDummyWithIgnoreAttributeAndPrivateProperty
{
public $foo = 'foo';

/** @Ignore */
#[Ignore]
public $ignored = 'ignored';

private $private = 'private';
Expand Down
16 changes: 7 additions & 9 deletions Tests/Normalizer/GetSetMethodNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Serializer\Attribute\DiscriminatorMap;
use Symfony\Component\Serializer\Exception\LogicException;
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
Expand Down Expand Up @@ -494,7 +494,7 @@ protected function getNormalizerForSkipUninitializedValues(): NormalizerInterfac

public function testNormalizeWithDiscriminator()
{
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
$discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
$normalizer = new GetSetMethodNormalizer($classMetadataFactory, null, null, $discriminator);

Expand All @@ -503,7 +503,7 @@ public function testNormalizeWithDiscriminator()

public function testDenormalizeWithDiscriminator()
{
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
$discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
$normalizer = new GetSetMethodNormalizer($classMetadataFactory, null, null, $discriminator);

Expand Down Expand Up @@ -777,12 +777,10 @@ public function __call($key, $value)
}
}

/**
* @DiscriminatorMap(typeProperty="type", mapping={
* "one" = GetSetMethodDiscriminatedDummyOne::class,
* "two" = GetSetMethodDiscriminatedDummyTwo::class,
* })
*/
#[DiscriminatorMap(typeProperty: 'type', mapping: [
'one' => GetSetMethodDiscriminatedDummyOne::class,
'two' => GetSetMethodDiscriminatedDummyTwo::class,
])]
interface GetSetMethodDummyInterface
{
}
Expand Down
16 changes: 7 additions & 9 deletions Tests/Normalizer/PropertyNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Serializer\Attribute\DiscriminatorMap;
use Symfony\Component\Serializer\Exception\LogicException;
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
Expand Down Expand Up @@ -499,7 +499,7 @@ protected function getNormalizerForSkipUninitializedValues(): NormalizerInterfac

public function testNormalizeWithDiscriminator()
{
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
$discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
$normalizer = new PropertyNormalizer($classMetadataFactory, null, null, $discriminator);

Expand All @@ -508,7 +508,7 @@ public function testNormalizeWithDiscriminator()

public function testDenormalizeWithDiscriminator()
{
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
$discriminator = new ClassDiscriminatorFromClassMetadata($classMetadataFactory);
$normalizer = new PropertyNormalizer($classMetadataFactory, null, null, $discriminator);

Expand Down Expand Up @@ -621,12 +621,10 @@ public function getIntMatrix(): array
}
}

/**
* @DiscriminatorMap(typeProperty="type", mapping={
* "one" = PropertyDiscriminatedDummyOne::class,
* "two" = PropertyDiscriminatedDummyTwo::class,
* })
*/
#[DiscriminatorMap(typeProperty: 'type', mapping: [
'one' => PropertyDiscriminatedDummyOne::class,
'two' => PropertyDiscriminatedDummyTwo::class,
])]
interface PropertyDummyInterface
{
}
Expand Down

0 comments on commit ff423e8

Please sign in to comment.