diff --git a/library/Rules/Not.php b/library/Rules/Not.php index bda4b55f..330c28c3 100644 --- a/library/Rules/Not.php +++ b/library/Rules/Not.php @@ -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)); diff --git a/tests/unit/Rules/NotTest.php b/tests/unit/Rules/NotTest.php index c95c5254..03b69a06 100644 --- a/tests/unit/Rules/NotTest.php +++ b/tests/unit/Rules/NotTest.php @@ -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())], + ]; + } }