|
27 | 27 | use Symfony\Component\Validator\Constraints\Range;
|
28 | 28 | use Symfony\Component\Validator\Constraints\Required;
|
29 | 29 | use Symfony\Component\Validator\Constraints\Sequentially;
|
| 30 | +use Symfony\Component\Validator\Constraints\Type; |
30 | 31 | use Symfony\Component\Validator\Constraints\Valid;
|
31 | 32 | use Symfony\Component\Validator\Mapping\ClassMetadata;
|
32 | 33 | use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader;
|
@@ -98,6 +99,7 @@ public function testLoadClassMetadata(string $namespace)
|
98 | 99 | $expected->addGetterConstraint('lastName', new NotNull());
|
99 | 100 | $expected->addGetterMethodConstraint('valid', 'isValid', new IsTrue());
|
100 | 101 | $expected->addGetterConstraint('permissions', new IsTrue());
|
| 102 | + $expected->addPropertyConstraint('other', new Type('integer')); |
101 | 103 |
|
102 | 104 | // load reflection class so that the comparison passes
|
103 | 105 | $expected->getReflectionClass();
|
@@ -139,18 +141,16 @@ public function testLoadClassMetadataAndMerge(string $namespace)
|
139 | 141 | $loader->loadClassMetadata($parent_metadata);
|
140 | 142 |
|
141 | 143 | $metadata = new ClassMetadata($namespace.'\Entity');
|
| 144 | + $loader->loadClassMetadata($metadata); |
142 | 145 |
|
143 | 146 | // Merge parent metaData.
|
144 | 147 | $metadata->mergeConstraints($parent_metadata);
|
145 | 148 |
|
146 |
| - $loader->loadClassMetadata($metadata); |
147 |
| - |
148 | 149 | $expected_parent = new ClassMetadata($namespace.'\EntityParent');
|
149 | 150 | $expected_parent->addPropertyConstraint('other', new NotNull());
|
150 | 151 | $expected_parent->getReflectionClass();
|
151 | 152 |
|
152 | 153 | $expected = new ClassMetadata($namespace.'\Entity');
|
153 |
| - $expected->mergeConstraints($expected_parent); |
154 | 154 |
|
155 | 155 | $expected->setGroupSequence(['Foo', 'Entity']);
|
156 | 156 | $expected->addConstraint(new ConstraintA());
|
@@ -187,11 +187,18 @@ public function testLoadClassMetadataAndMerge(string $namespace)
|
187 | 187 | $expected->addGetterConstraint('lastName', new NotNull());
|
188 | 188 | $expected->addGetterMethodConstraint('valid', 'isValid', new IsTrue());
|
189 | 189 | $expected->addGetterConstraint('permissions', new IsTrue());
|
| 190 | + $expected->addPropertyConstraint('other', new Type('integer')); |
190 | 191 |
|
191 | 192 | // load reflection class so that the comparison passes
|
192 | 193 | $expected->getReflectionClass();
|
| 194 | + $expected->mergeConstraints($expected_parent); |
193 | 195 |
|
194 | 196 | $this->assertEquals($expected, $metadata);
|
| 197 | + |
| 198 | + $otherMetadata = $metadata->getPropertyMetadata('other'); |
| 199 | + $this->assertCount(2, $otherMetadata); |
| 200 | + $this->assertInstanceOf(Type::class, $otherMetadata[0]->getConstraints()[0]); |
| 201 | + $this->assertInstanceOf(NotNull::class, $otherMetadata[1]->getConstraints()[0]); |
195 | 202 | }
|
196 | 203 |
|
197 | 204 | /**
|
|
0 commit comments