1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Validator\Tests\Mapping\Loader;
use Doctrine\Common\Annotations\AnnotationReader;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
#[\PHPUnit\Framework\Attributes\Group('legacy')]
class AnnotationLoaderWithHybridAnnotationsTest extends AttributeLoaderTest
{
use ExpectDeprecationTrait;
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
public function testLoadClassMetadataReturnsTrueIfSuccessful()
{
$this->expectDeprecation('Since symfony/validator 6.4: Class "Symfony\Component\Validator\Tests\Fixtures\Attribute\Entity" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
$this->expectDeprecation('Since symfony/validator 6.4: Property "Symfony\Component\Validator\Tests\Fixtures\Attribute\Entity::$firstName" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
parent::testLoadClassMetadataReturnsTrueIfSuccessful();
}
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
public function testLoadClassMetadata()
{
$this->expectDeprecation('Since symfony/validator 6.4: Class "Symfony\Component\Validator\Tests\Fixtures\Attribute\Entity" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
$this->expectDeprecation('Since symfony/validator 6.4: Property "Symfony\Component\Validator\Tests\Fixtures\Attribute\Entity::$firstName" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
parent::testLoadClassMetadata();
}
#[\PHPUnit\Framework\Attributes\DoesNotPerformAssertions]
public function testLoadClassMetadataAndMerge()
{
$this->expectDeprecation('Since symfony/validator 6.4: Class "Symfony\Component\Validator\Tests\Fixtures\Attribute\Entity" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
$this->expectDeprecation('Since symfony/validator 6.4: Property "Symfony\Component\Validator\Tests\Fixtures\Attribute\Entity::$firstName" uses Doctrine Annotations to configure validation constraints, which is deprecated. Use PHP attributes instead.');
parent::testLoadClassMetadataAndMerge();
}
public function testLoadClassMetadataWithOtherAnnotations()
{
$loader = $this->createAnnotationLoader();
$metadata = new ClassMetadata(EntityWithOtherAnnotations::class);
$this->assertTrue($loader->loadClassMetadata($metadata));
}
protected function createAnnotationLoader(): AnnotationLoader
{
return new AnnotationLoader(new AnnotationReader());
}
protected function getFixtureNamespace(): string
{
return 'Symfony\Component\Validator\Tests\Fixtures\Attribute';
}
}
/**
* @Annotation
* @Target({"PROPERTY"})
*/
class SomeAnnotation
{
}
class EntityWithOtherAnnotations
{
/**
* @SomeAnnotation
*/
#[NotBlank]
public ?string $name = null;
}
|