10000 ensure that tests are run with lowest supported Serializer versions · symfony/symfony@7ff3bb3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ff3bb3

Browse files
committed
ensure that tests are run with lowest supported Serializer versions
1 parent eb9e923 commit 7ff3bb3

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

src/Symfony/Component/PropertyInfo/Tests/Extractor/SerializerExtractorTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
namespace Symfony\Component\PropertyInfo\Tests\Extractor;
1313

14+
use Doctrine\Common\Annotations\AnnotationReader;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\PropertyInfo\Extractor\SerializerExtractor;
1617
use Symfony\Component\PropertyInfo\Tests\Fixtures\AdderRemoverDummy;
1718
use Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy;
1819
use Symfony\Component\PropertyInfo\Tests\Fixtures\IgnorePropertyDummy;
1920
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
21+
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
2022
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
2123

2224
/**
@@ -28,7 +30,11 @@ class SerializerExtractorTest extends TestCase
2830

2931
protected function setUp(): void
3032
{
31-
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
33+
if (class_exists(AttributeLoader::class)) {
34+
$classMetadataFactory = new ClassMetadataFactory(new AttributeLoader());
35+
} else {
36+
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
37+
}
3238
$this->extractor = new SerializerExtractor($classMetadataFactory);
3339
}
3440

src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\PropertyInfo\Tests\Fixtures;
1313

14+
use Symfony\Component\Serializer\Annotation\Groups as GroupsAnnotation;
1415
use Symfony\Component\Serializer\Attribute\Groups;
1516

1617
/**
@@ -42,6 +43,7 @@ class Dummy extends ParentDummy
4243

4344
/**
4445
* @var \DateTimeImmutable[]
46+
* @GroupsAnnotation({"a", "b"})
4547
*/
4648
#[Groups(['a', 'b'])]
4749
public $collection;

src/Symfony/Component/PropertyInfo/Tests/Fixtures/IgnorePropertyDummy.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\PropertyInfo\Tests\Fixtures;
1313

14+
use Symfony\Component\Serializer\Annotation\Groups as GroupsAnnotation;
15+
use Symfony\Component\Serializer\Annotation\Ignore as IgnoreAnnotation;
1416
use Symfony\Component\Serializer\Attribute\Groups;
1517
use Symfony\Component\Serializer\Attribute\Ignore;
1618

@@ -19,9 +21,16 @@
1921
*/
2022
class IgnorePropertyDummy
2123
{
24+
/**
25+
* @GroupsAnnotation({"a"})
26+
*/
2227
#[Groups(['a'])]
2328
public $visibleProperty;
2429

30+
/**
31+
* @GroupsAnnotation({"a"})
32+
* @IgnoreAnnotation
33+
*/
2534
#[Groups(['a']), Ignore]
2635
private $ignoredProperty;
2736
}

src/Symfony/Component/PropertyInfo/composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,19 @@
2727
"symfony/string": "^5.4|^6.0|^7.0"
2828
},
2929
"require-dev": {
30-
"symfony/serializer": "^6.4|^7.0",
30+
"doctrine/annotations": "^1.12|^2",
31+
"symfony/serializer": "^5.4|^6.4|^7.0",
3132
"symfony/cache": "^5.4|^6.0|^7.0",
3233
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
3334
"phpdocumentor/reflection-docblock": "^5.2",
3435
"phpstan/phpdoc-parser": "^1.0|^2.0"
3536
},
3637
"conflict": {
38+
"doctrine/annotations": "<1.12",
3739
"phpdocumentor/reflection-docblock": "<5.2",
3840
"phpdocumentor/type-resolver": "<1.5.1",
39-
"symfony/dependency-injection": "<5.4"
41+
"symfony/dependency-injection": "<5.4",
42+
"symfony/dependency-injection": "<5.4|>=6.0,<6.4"
4043
},
4144
"autoload": {
4245
"psr-4": { "Symfony\\Component\\PropertyInfo\\": "" },

0 commit comments

Comments
 (0)
0