From d9f87f40450f3b0a56a0eca46603236c6e558f63 Mon Sep 17 00:00:00 2001 From: Suralc Date: Tue, 13 Aug 2013 16:49:53 +0200 Subject: [PATCH] Added RequiredValidatorTest --- .../framework/validators/RequiredValidatorTest.php | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/unit/framework/validators/RequiredValidatorTest.php diff --git a/tests/unit/framework/validators/RequiredValidatorTest.php b/tests/unit/framework/validators/RequiredValidatorTest.php new file mode 100644 index 0000000..198727b --- /dev/null +++ b/tests/unit/framework/validators/RequiredValidatorTest.php @@ -0,0 +1,34 @@ +assertFalse($val->validateValue(null)); + $this->assertFalse($val->validateValue(array())); + $this->assertTrue($val->validateValue('not empty')); + $this->assertTrue($val->validateValue(array('with', 'elements'))); + } + + public function testValidateValueWithValue() + { + $val = new RequiredValidator(array('requiredValue' => 55)); + $this->assertTrue($val->validateValue(55)); + $this->assertTrue($val->validateValue("55")); + $this->assertTrue($val->validateValue("0x37")); + $this->assertFalse($val->validateValue("should fail")); + $this->assertTrue($val->validateValue(true)); + $val->strict = true; + $this->assertTrue($val->validateValue(55)); + $this->assertFalse($val->validateValue("55")); + $this->assertFalse($val->validateValue("0x37")); + $this->assertFalse($val->validateValue("should fail")); + $this->assertFalse($val->validateValue(true)); + } +} \ No newline at end of file