Skip to content

[PropertyInfo] ensure that tests are run with lowest supported Serializer versions #59010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@

namespace Symfony\Component\PropertyInfo\Tests\Extractor;

use Doctrine\Common\Annotations\AnnotationReader;
use PHPUnit\Framework\TestCase;
use Symfony\Component\PropertyInfo\Extractor\SerializerExtractor;
use Symfony\Component\PropertyInfo\Tests\Fixtures\AdderRemoverDummy;
use Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy;
use Symfony\Component\PropertyInfo\Tests\Fixtures\IgnorePropertyDummy;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;

/**
Expand All @@ -28,7 +30,11 @@ class SerializerExtractorTest extends TestCase

protected function setUp(): void
{
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
if (class_exists(AttributeLoader::class)) {
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
} else {
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
}
$this->extractor = new SerializerExtractor($classMetadataFactory);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\PropertyInfo\Tests\Fixtures;

use Symfony\Component\Serializer\Annotation\Groups as GroupsAnnotation;
use Symfony\Component\Serializer\Attribute\Groups;

/**
Expand Down Expand Up @@ -42,6 +43,7 @@ class Dummy extends ParentDummy

/**
* @var \DateTimeImmutable[]
* @GroupsAnnotation({"a", "b"})
*/
#[Groups(['a', 'b'])]
public $collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Component\PropertyInfo\Tests\Fixtures;

use Symfony\Component\Serializer\Annotation\Groups as GroupsAnnotation;
use Symfony\Component\Serializer\Annotation\Ignore as IgnoreAnnotation;
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Serializer\Attribute\Ignore;

Expand All @@ -19,9 +21,16 @@
*/
class IgnorePropertyDummy
{
/**
* @GroupsAnnotation({"a"})
*/
#[Groups(['a'])]
public $visibleProperty;

/**
* @GroupsAnnotation({"a"})
* @IgnoreAnnotation
*/
#[Groups(['a']), Ignore]
private $ignoredProperty;
}
7 changes: 5 additions & 2 deletions src/Symfony/Component/PropertyInfo/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@
"symfony/string": "^5.4|^6.0|^7.0"
},
"require-dev": {
"symfony/serializer": "^6.4|^7.0",
"doctrine/annotations": "^1.12|^2",
"symfony/serializer": "^5.4|^6.4|^7.0",
"symfony/cache": "^5.4|^6.0|^7.0",
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
"phpdocumentor/reflection-docblock": "^5.2",
"phpstan/phpdoc-parser": "^1.0|^2.0"
},
"conflict": {
"doctrine/annotations": "<1.12",
"phpdocumentor/reflection-docblock": "<5.2",
"phpdocumentor/type-resolver": "<1.5.1",
"symfony/dependency-injection": "<5.4"
"symfony/dependency-injection": "<5.4",
"symfony/dependency-injection": "<5.4|>=6.0,<6.4"
},
"autoload": {
"psr-4": { "Symfony\\Component\\PropertyInfo\\": "" },
Expand Down