diff --git a/src/Validation/ValidationRule.php b/src/Validation/ValidationRule.php index e95a88db948..2b30dea27b8 100644 --- a/src/Validation/ValidationRule.php +++ b/src/Validation/ValidationRule.php @@ -134,7 +134,7 @@ public function process($value, array $providers, array $context = []) } if ($this->_pass) { - $args = array_merge([$value], $this->_pass, [$context]); + $args = array_values(array_merge([$value], $this->_pass, [$context])); $result = $callable(...$args); } else { $result = $callable($value, $context); diff --git a/tests/TestCase/Validation/ValidationRuleTest.php b/tests/TestCase/Validation/ValidationRuleTest.php index c0ae12fb171..0ba610381f3 100644 --- a/tests/TestCase/Validation/ValidationRuleTest.php +++ b/tests/TestCase/Validation/ValidationRuleTest.php @@ -67,7 +67,7 @@ public function testCustomMethods() $Rule = new ValidationRule(['rule' => 'willFail']); $this->assertFalse($Rule->process($data, $providers, $context)); - $Rule = new ValidationRule(['rule' => 'willPass']); + $Rule = new ValidationRule(['rule' => 'willPass', 'pass' => ['key' => 'value']]); $this->assertTrue($Rule->process($data, $providers, $context)); $Rule = new ValidationRule(['rule' => 'willFail3']);