File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -274,7 +274,7 @@ public function getTargets()
274
274
public function __sleep ()
275
275
{
276
276
// Initialize "groups" option if it is not set
277
- $ this ->__get ( ' groups ' ) ;
277
+ $ this ->groups ;
278
278
279
279
return array_keys (get_object_vars ($ this ));
280
280
}
Original file line number Diff line number Diff line change @@ -167,22 +167,34 @@ public function testSerialize()
167
167
$ this ->assertEquals ($ constraint , $ restoredConstraint );
168
168
}
169
169
170
- public function testSerializeInitializesGroupsOption ()
170
+ public function testSerializeInitializesGroupsOptionToDefault ()
171
171
{
172
- $ constraintWithExplicitGroup = new ConstraintA (array (
172
+ $ constraint = new ConstraintA (array (
173
+ 'property1 ' => 'foo ' ,
174
+ 'property2 ' => 'bar ' ,
175
+ ));
176
+
177
+ $ constraint = unserialize (serialize ($ constraint ));
178
+
179
+ $ expected = new ConstraintA (array (
173
180
'property1 ' => 'foo ' ,
174
181
'property2 ' => 'bar ' ,
175
182
'groups ' => 'Default ' ,
176
183
));
177
184
178
- $ constraintWithoutExplicitGroup = new ConstraintA (array (
185
+ $ this ->assertEquals ($ expected , $ constraint );
186
+ }
187
+
188
+ public function testSerializeKeepsCustomGroups ()
189
+ {
190
+ $ constraint = new ConstraintA (array (
179
191
'property1 ' => 'foo ' ,
180
192
'property2 ' => 'bar ' ,
193
+ 'groups ' => 'MyGroup ' ,
181
194
));
182
195
183
- $ constraintWithExplicitGroup = unserialize (serialize ($ constraintWithExplicitGroup ));
184
- $ constraintWithoutExplicitGroup = unserialize (serialize ($ constraintWithoutExplicitGroup ));
196
+ $ constraint = unserialize (serialize ($ constraint ));
185
197
186
- $ this ->assertEquals ( $ constraintWithExplicitGroup , $ constraintWithoutExplicitGroup );
198
+ $ this ->assertSame ( array ( ' MyGroup ' ) , $ constraint -> groups );
187
199
}
188
200
}
You can’t perform that action at this time.
0 commit comments