@@ -49,4 +49,40 @@ public function getExclusionRules()
4949 [['foo ' ], [GroupsExclusionStrategy::DEFAULT_GROUP , 'foo ' ], false ],
5050 ];
5151 }
52+
53+ /**
54+ * @dataProvider getGroupsFor
55+ * @param $groups
56+ * @param $propsVisited
57+ * @param $resultingGroups
58+ */
59+ public function testGroupsFor ($ groups , $ propsVisited , $ resultingGroups )
60+ {
61+ $ exclusion = new GroupsExclusionStrategy ($ groups );
62+ $ context = SerializationContext::create ();
63+
64+ foreach ($ propsVisited as $ prop ) {
65+ $ metadata = new StaticPropertyMetadata ('stdClass ' , $ prop , 'propVal ' );
66+ $ context ->pushPropertyMetadata ($ metadata );
67+ }
68+
69+ $ groupsFor = $ exclusion ->getGroupsFor ($ context );
70+ $ this ->assertEquals ($ groupsFor , $ resultingGroups );
71+ }
72+
73+ public function getGroupsFor ()
74+ {
75+ return [
76+ [['foo ' ], ['prop ' ], ['foo ' ]],
77+ [[], ['prop ' ], ['Default ' ]],
78+
79+ [['foo ' , 'prop ' => ['bar ' ]], ['prop ' ], ['bar ' ]],
80+ [['foo ' , 'prop ' => ['bar ' ]], ['prop2 ' ], ['foo ' , 'prop ' => ['bar ' ]]],
81+
82+ [['foo ' , 'prop ' => ['bar ' ]], ['prop ' , 'prop2 ' ], ['Default ' ]],
83+
84+ [['foo ' , 'prop ' => ['xx ' , 'prop2 ' => ['def ' ], 'prop3 ' => ['def ' ]]], ['prop ' , 'prop2 ' , 'propB ' ], ['Default ' ]],
85+ [['foo ' , 'prop ' => ['xx ' , 'prop2 ' => ['def ' , 'prop3 ' => ['def ' ]]]], ['prop ' , 'prop2 ' ], ['def ' , 'prop3 ' => ['def ' ]]],
86+ ];
87+ }
5288}
0 commit comments