mirror of
https://github.com/Respect/Validation.git
synced 2024-06-29 02:30:06 +02:00
Fix wrong behavior when calling not()
rule
This commit is contained in:
parent
856d8fd1d1
commit
fb54341fb2
|
@ -146,8 +146,8 @@ class Validator extends AllOf
|
|||
*/
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
if ('not' === $method) {
|
||||
return $arguments ? static::buildRule($method, $arguments) : new Rules\Not($this);
|
||||
if ('not' === $method && empty($arguments)) {
|
||||
return new static(new Rules\Not($this));
|
||||
}
|
||||
|
||||
return $this->addRule(static::buildRule($method, $arguments));
|
||||
|
|
|
@ -90,5 +90,24 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
|
|||
\-"" must be a valid date', $e->getFullMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test #174.
|
||||
*/
|
||||
public function testShouldReturnANewValidatorInstanceWhenTheNotRuleIsCalledWithoutAnyArgument()
|
||||
{
|
||||
$validator = new Validator();
|
||||
|
||||
$this->assertInstanceOf('Respect\Validation\Validator', $validator->not());
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression test #174.
|
||||
*/
|
||||
public function testShouldReturnValidatorInstanceWhenTheNotRuleIsCalledWithArguments()
|
||||
{
|
||||
$validator = new Validator();
|
||||
|
||||
$this->assertSame($validator, $validator->not($validator->notEmpty()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue