Skip to content
Permalink
Browse files

Fix Validator::equals() never passing.

This method would always trigger validation errors as the conditions
were incorrectly defined.

Refs #9238
  • Loading branch information...
markstory committed Aug 9, 2016
1 parent 3d3e354 commit 26e6bf06d55c9414699bcc9cadca37087a5b261c
Showing with 3 additions and 2 deletions.
  1. +1 −1 src/Validation/Validator.php
  2. +2 −1 tests/TestCase/Validation/ValidatorTest.php
@@ -729,7 +729,7 @@ public function equals($field, $value, $message = null, $when = null)
$extra = array_filter(['on' => $when, 'message' => $message]);
return $this->add($field, 'equals', $extra + [
'rule' => ['comparison', '=', $value]
'rule' => ['comparison', '==', $value]
]);
}
@@ -1190,7 +1190,8 @@ public function testLessThanOrEqual()
public function testEquals()
{
$validator = new Validator();
$this->assertProxyMethod($validator, 'equals', 5, ['=', 5], 'comparison');
$this->assertProxyMethod($validator, 'equals', 5, ['==', 5], 'comparison');
$this->assertEmpty($validator->errors(['username' => 5]));
$this->assertNotEmpty($validator->errors(['username' => 6]));
}

0 comments on commit 26e6bf0

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.