@@ -21,13 +21,15 @@ class LazyLoadingMetadataFactoryTest extends \PHPUnit_Framework_TestCase
21
21
const CLASSNAME = 'Symfony\Component\Validator\Tests\Fixtures\Entity ' ;
22
22
const PARENTCLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParent ' ;
23
23
const INTERFACECLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityInterface ' ;
24
+ const PARENTINTERFACECLASS = 'Symfony\Component\Validator\Tests\Fixtures\EntityParentInterface ' ;
24
25
25
26
public function testLoadClassMetadataWithInterface ()
26
27
{
27
28
$ factory = new LazyLoadingMetadataFactory (new TestLoader ());
28
29
$ metadata = $ factory ->getMetadataFor (self ::PARENTCLASS );
29
30
30
31
$ constraints = array (
32
+ new ConstraintA (array ('groups ' => array ('Default ' , 'EntityParentInterface ' , 'EntityInterface ' , 'EntityParent ' ))),
31
33
new ConstraintA (array ('groups ' => array ('Default ' , 'EntityInterface ' , 'EntityParent ' ))),
32
34
new ConstraintA (array ('groups ' => array ('Default ' , 'EntityParent ' ))),
33
35
);
@@ -41,6 +43,13 @@ public function testMergeParentConstraints()
41
43
$ metadata = $ factory ->getMetadataFor (self ::CLASSNAME );
42
44
43
45
$ constraints = array (
46
+ new ConstraintA (array ('groups ' => array (
47
+ 'Default ' ,
48
+ 'EntityParentInterface ' ,
49
+ 'EntityInterface ' ,
50
+ 'EntityParent ' ,
51
+ 'Entity ' ,
52
+ ))),
44
53
new ConstraintA (array ('groups ' => array (
45
54
'Default ' ,
46
55
'EntityInterface ' ,
@@ -67,23 +76,32 @@ public function testWriteMetadataToCache()
67
76
$ factory = new LazyLoadingMetadataFactory (new TestLoader (), $ cache );
68
77
69
78
$ parentClassConstraints = array (
79
+ new ConstraintA (array ('groups ' => array ('Default ' , 'EntityParentInterface ' , 'EntityInterface ' , 'EntityParent ' ))),
70
80
new ConstraintA (array ('groups ' => array ('Default ' , 'EntityInterface ' , 'EntityParent ' ))),
71
81
new ConstraintA (array ('groups ' => array ('Default ' , 'EntityParent ' ))),
72
82
);
73
- $ interfaceConstraints = array (new ConstraintA (array ('groups ' => array ('Default ' , 'EntityInterface ' ))));
83
+ $ interfaceConstraints = array (
84
+ new ConstraintA (array ('groups ' => array ('Default ' , 'EntityParentInterface ' , 'EntityInterface ' ))),
85
+ new ConstraintA (array ('groups ' => array ('Default ' , 'EntityParentInterface ' ))),
86
+ );
87
+ $ parentInterfaceConstraints = array (new ConstraintA (array ('groups ' => array ('Default ' , 'EntityParentInterface ' ))));
74
88
75
89
$ cache ->expects ($ this ->never ())
76
90
->method ('has ' );
77
- $ cache ->expects ($ this ->exactly (2 ))
91
+ $ cache ->expects ($ this ->exactly (3 ))
78
92
->method ('read ' )
79
93
->withConsecutive (
80
94
array ($ this ->equalTo (self ::PARENTCLASS )),
81
- array ($ this ->equalTo (self ::INTERFACECLASS ))
95
+ array ($ this ->equalTo (self ::INTERFACECLASS )),
96
+ array ($ this ->equalTo (self ::PARENTINTERFACECLASS ))
82
97
)
83
98
->will ($ this ->returnValue (false ));
84
- $ cache ->expects ($ this ->exactly (2 ))
99
+ $ cache ->expects ($ this ->exactly (3 ))
85
100
->method ('write ' )
86
101
->withConsecutive (
102
+ $ this ->callback (function ($ metadata ) use ($ parentInterfaceConstraints ) {
103
+ return $ parentInterfaceConstraints == $ metadata ->getConstraints ();
104
+ }),
87
105
$ this ->callback (function ($ metadata ) use ($ interfaceConstraints ) {
88
106
return $ interfaceConstraints == $ metadata ->getConstraints ();
89
107
}),
0 commit comments