8000 [2.2] [WIP][Validator][Constraints][Collection] walk constraints by groups by gator92 · Pull Request #4453 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[2.2] [WIP][Validator][Constraints][Collection] walk constraints by groups #4453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests add CollectionByGroup test
  • Loading branch information
gator92 committed May 5, 2013
commit 237fb1124b3589425f83bfa46412be8718d7cb12
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function testWalkMultipleConstraints()
{
$constraints = array(
new Range(array('min' => 4)),
new NotNull(),
new NotNull(array('groups' => 'MyGroup')),
);

$array = array(
Expand Down Expand Up @@ -289,7 +289,7 @@ public function testOptionalFieldMultipleConstraints()
);

$constraints = array(
new NotNull(),
new NotNull(array('groups' => 'MyGroup')),
new Range(array('min' => 4)),
);
$i = 1;
Expand Down Expand Up @@ -371,7 +371,7 @@ public function testRequiredFieldMultipleConstraints()
);

$constraints = array(
new NotNull(),
new NotNull(array('groups' => 'MyGroup')),
new Range(array('min' => 4)),
);
$i = 1;
Expand Down Expand Up @@ -408,4 +408,31 @@ public function testObjectShouldBeLeftUnchanged()
'foo' => 3
), (array) $value);
}

public function testWalkbyGroup()
{
$array = array(
'foo' => 2,
);

$constraints = array(
new Min(array('limit' => 5, 'groups' => 'MyGroup')),
new Min(array('limit' => 3, 'groups' => 'YourGroup')),
);

$this->walker->expects($this->once())
->method('walkConstraint')
->with($constraints[0], $array['foo'], 'MyGroup', 'foo.bar[foo]');

$this->context->expects($this->never())
->method('addViolationAtSubPath');

$data = $this->prepareTestData($array);

$this->validator->validate($data, new Collection(array(
'fields' => array(
'foo' => $constraints,
)
)));
}
}
0