8000 [Validator] fixed remaining notice by fabpot · Pull Request #13435 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] fixed remaining notice #13435

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

Merged
merged 2 commits into from
Jan 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load fil 8000 es.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,21 @@ public function validate($value, Constraint $constraint)
if (!$constraint->allowExtraFields) {
foreach ($value as $field => $fieldValue) {
if (!isset($constraint->fields[$field])) {
$this->buildViolationInContext($context, $constraint->extraFieldsMessage)
->atPath('['.$field.']')
->setParameter('{{ field }}', $this->formatValue($field))
->setInvalidValue($fieldValue)
->setCode(Collection::NO_SUCH_FIELD_ERROR)
->addViolation();
if ($context instanceof ExecutionContextInterface) {
$context->buildViolation($constraint->extraFieldsMessage)
->atPath('['.$field.']')
->setParameter('{{ field }}', $this->formatValue($field))
->setInvalidValue($fieldValue)
->setCode(Collection::NO_SUCH_FIELD_ERROR)
->addViolation();
} else {
$this->buildViolationInContext($context, $constraint->extraFieldsMessage)
->atPath('['.$field.']')
->setParameter('{{ field }}', $this->formatValue($field))
->setInvalidValue($fieldValue)
->setCode(Collection::NO_SUCH_FIELD_ERROR)
->addViolation();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,21 @@ protected function tearDown()
$this->metadata = null;
}

public function testAddValidSetsMemberToCascaded()
public function testLegacyAddValidSetsMemberToCascaded()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

$result = $this->metadata->addConstraint(new Valid());

$this->assertEquals(array(), $this->metadata->getConstraints());
$this->assertEquals($result, $this->metadata);
$this->assertTrue($this->metadata->isCascaded());
}

public function testAddOtherConstraintDoesNotSetMemberToCascaded()
public function testLegacyAddOtherConstraintDoesNotSetMemberToCascaded()
{
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);

$result = $this->metadata->addConstraint($constraint = new ConstraintA());

$this->assertEquals(array($constraint), $this->metadata->getConstraints());
Expand Down
0