|
11 | 11 |
|
12 | 12 | namespace Symfony\Bridge\Doctrine\Tests\Validator; |
13 | 13 |
|
| 14 | +use Doctrine\ORM\Mapping\Column; |
14 | 15 | use PHPUnit\Framework\TestCase; |
15 | 16 | use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; |
16 | 17 | use Symfony\Bridge\Doctrine\Tests\Fixtures\BaseUser; |
17 | 18 | use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderEmbed; |
18 | 19 | use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderEntity; |
| 20 | +use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderEnum; |
19 | 21 | use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderNestedEmbed; |
20 | 22 | use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderNoAutoMappingEntity; |
21 | 23 | use Symfony\Bridge\Doctrine\Tests\Fixtures\DoctrineLoaderParentEntity; |
@@ -149,6 +151,31 @@ public function testLoadClassMetadata() |
149 | 151 | $this->assertSame(AutoMappingStrategy::DISABLED, $noAutoMappingMetadata[0]->getAutoMappingStrategy()); |
150 | 152 | } |
151 | 153 |
|
| 154 | + /** |
| 155 | + * @requires PHP 8.1 |
| 156 | + */ |
| 157 | + public function testExtractEnum() |
| 158 | + { |
| 159 | + if (!property_exists(Column::class, 'enumType')) { |
| 160 | + $this->markTestSkipped('The "enumType" requires doctrine/orm 2.11.'); |
| 161 | + } |
| 162 | + |
| 163 | + $validator = Validation::createValidatorBuilder() |
| 164 | + ->addMethodMapping('loadValidatorMetadata') |
| 165 | + ->enableAnnotationMapping() |
| 166 | + ->addLoader(new DoctrineLoader(DoctrineTestHelper::createTestEntityManager(), '{^Symfony\\\\Bridge\\\\Doctrine\\\\Tests\\\\Fixtures\\\\DoctrineLoader}')) |
| 167 | + ->getValidator() |
| 168 | + ; |
| 169 | + |
| 170 | + $classMetadata = $validator->getMetadataFor(new DoctrineLoaderEnum()); |
| 171 | + |
| 172 | + $enumStringMetadata = $classMetadata->getPropertyMetadata('enumString'); |
| 173 | + $this->assertCount(0, $enumStringMetadata); // asserts the length constraint is not added to an enum |
| 174 | + |
| 175 | + $enumStringMetadata = $classMetadata->getPropertyMetadata('enumInt'); |
| 176 | + $this->assertCount(0, $enumStringMetadata); // asserts the length constraint is not added to an enum |
| 177 | + } |
| 178 | + |
152 | 179 | public function testFieldMappingsConfiguration() |
153 | 180 | { |
154 | 181 | $validator = Validation::createValidatorBuilder() |
|
0 commit comments