File tree 4 files changed +86
-0
lines changed
src/Symfony/Component/Validator/Tests
4 files changed +86
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Component \Validator \Tests \Fixtures ;
13
+
14
+ use Symfony \Component \Validator \Mapping \ClassMetadata ;
15
+ use Symfony \Component \Validator \Constraints \Length ;
16
+
17
+ class EntityStaticCar extends EntityStaticVehicle
18
+ {
19
+ public static function loadValidatorMetadata (ClassMetadata $ metadata )
20
+ {
21
+ $ metadata ->addPropertyConstraint ('wheels ' , new Length (array ('max ' => 99 )));
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Component \Validator \Tests \Fixtures ;
13
+
14
+ use Symfony \Component \Validator \Mapping \ClassMetadata ;
15
+ use Symfony \Component \Validator \Constraints \Length ;
16
+
17
+ class EntityStaticCarTurbo extends EntityStaticCar
18
+ {
19
+ public static function loadValidatorMetadata (ClassMetadata $ metadata )
20
+ {
21
+ $ metadata ->addPropertyConstraint ('wheels ' , new Length (array ('max ' => 99 )));
22
+ }
23
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Component \Validator \Tests \Fixtures ;
13
+
14
+ use Symfony \Component \Validator \Mapping \ClassMetadata ;
15
+ use Symfony \Component \Validator \Constraints \Length ;
16
+
17
+ class EntityStaticVehicle
18
+ {
19
+ public $ wheels ;
20
+
21
+ public static function loadValidatorMetadata (ClassMetadata $ metadata )
22
+ {
23
+ $ metadata ->addPropertyConstraint ('wheels ' , new Length (array ('max ' => 99 )));
24
+ }
25
+ }
Original file line number Diff line number Diff line change @@ -168,6 +168,21 @@ public function testMetadataCacheWithRuntimeConstraint()
168
168
169
169
$ metadata = $ factory ->getMetadataFor (self ::CLASS_NAME );
170
170
}
171
+
172
+ public function testGroupsFromParent ()
173
+ {
174
+ $ reader = new \Symfony \Component \Validator \Mapping \Loader \StaticMethodLoader ();
175
+ $ factory = new LazyLoadingMetadataFactory ($ reader );
176
+ $ metadata = $ factory ->getMetadataFor ('Symfony\Component\Validator\Tests\Fixtures\EntityStaticCarTurbo ' );
177
+ $ classMetaData = $ metadata ->getPropertyMetadata ('wheels ' );
178
+ $ constraints = $ classMetaData [0 ]->getConstraints ();
179
+ $ groups = $ constraints [0 ]->groups ;
180
+
181
+ $ this ->assertContains ('Default ' , $ groups );
182
+ $ this ->assertContains ('EntityStaticCarTurbo ' , $ groups );
183
+ $ this ->assertContains ('EntityStaticCar ' , $ groups );
184
+ $ this ->assertContains ('EntityStaticVehicle ' , $ groups );
185
+ }
171
186
}
172
187
173
188
class TestLoader implements LoaderInterface
You can’t perform that action at this time.
0 commit comments