mirror of
https://github.com/Respect/Validation.git
synced 2024-06-26 01:00:19 +02:00
Define names for the child of Not rule
This commit is contained in:
parent
6d04b77762
commit
d1c3b2596e
|
@ -23,6 +23,13 @@ class Not extends AbstractRule
|
|||
$this->rule = $rule;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$this->rule->setName($name);
|
||||
|
||||
return parent::setName($name);
|
||||
}
|
||||
|
||||
public function validate($input)
|
||||
{
|
||||
return (false == $this->rule->validate($input));
|
||||
|
|
|
@ -39,6 +39,18 @@ class NotTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertFalse($not->assert($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerForSetName
|
||||
*/
|
||||
public function testNotSetName($v)
|
||||
{
|
||||
$not = new Not($v);
|
||||
$not->setName('Foo');
|
||||
|
||||
$this->assertEquals('Foo', $not->getName());
|
||||
$this->assertEquals('Foo', $v->getName());
|
||||
}
|
||||
|
||||
public function providerForValidNot()
|
||||
{
|
||||
return [
|
||||
|
@ -62,4 +74,15 @@ class NotTest extends \PHPUnit_Framework_TestCase
|
|||
[Validator::oneOf(Validator::numeric(), Validator::intVal()), 13.37],
|
||||
];
|
||||
}
|
||||
|
||||
public function providerForSetName()
|
||||
{
|
||||
return [
|
||||
[new IntVal()],
|
||||
[new AllOf(new Numeric, new IntVal)],
|
||||
[new Not(new Not(new IntVal()))],
|
||||
[Validator::intVal()->setName('Bar')],
|
||||
[Validator::noneOf(Validator::numeric(), Validator::intVal())],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue