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