Skip to content

Commit

Permalink
minor #59010 [PropertyInfo] ensure that tests are run with lowest sup…
Browse files Browse the repository at this point in the history
…ported Serializer versions (xabbuh)

This PR was merged into the 6.4 branch.

Discussion
----------

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

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

Commits
-------

7ff3bb3de59 ensure that tests are run with lowest supported Serializer versions
  • Loading branch information
nicolas-grekas committed Nov 27, 2024
2 parents 739b5e3 + 317831c commit e4782ec
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Tests/Extractor/SerializerExtractorTest.php
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 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
9 changes: 9 additions & 0 deletions Tests/Fixtures/IgnorePropertyDummy.php
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 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

0 comments on commit e4782ec

Please sign in to comment.