diff --git a/tests/unit/framework/validators/DateValidatorTest.php b/tests/unit/framework/validators/DateValidatorTest.php index 30a515e..a551889 100644 --- a/tests/unit/framework/validators/DateValidatorTest.php +++ b/tests/unit/framework/validators/DateValidatorTest.php @@ -55,7 +55,10 @@ class DateValidatorTest extends TestCase DateTime::createFromFormat($val->format, '2013-09-13')->getTimestamp(), $model->attr_timestamp ); - + $val = new DateValidator(); + $model = FakedValidationModel::createWithAttributes(array('attr_date' => array())); + $val->validateAttribute($model, 'attr_date'); + $this->assertTrue($model->hasErrors('attr_date')); } } \ No newline at end of file diff --git a/tests/unit/framework/validators/ExistValidatorTest.php b/tests/unit/framework/validators/ExistValidatorTest.php index 6a1e5fe..930712c 100644 --- a/tests/unit/framework/validators/ExistValidatorTest.php +++ b/tests/unit/framework/validators/ExistValidatorTest.php @@ -90,5 +90,11 @@ class ExistValidatorTest extends DatabaseTestCase $m->a_field = 'some new value'; $val->validateAttribute($m, 'a_field'); $this->assertTrue($m->hasErrors('a_field')); + // check array + $val = new ExistValidator(array('attributeName' => 'ref')); + $m = ExistValidatorRefModel::find(array('id' => 2)); + $m->test_val = array(1,2,3); + $val->validateAttribute($m, 'test_val'); + $this->assertTrue($m->hasErrors('test_val')); } } \ No newline at end of file diff --git a/tests/unit/framework/validators/NumberValidatorTest.php b/tests/unit/framework/validators/NumberValidatorTest.php index 4868503..fa158d3 100644 --- a/tests/unit/framework/validators/NumberValidatorTest.php +++ b/tests/unit/framework/validators/NumberValidatorTest.php @@ -137,6 +137,10 @@ class NumberValidatorTest extends TestCase $model->attr_number = 3.43; $val->validateAttribute($model, 'attr_number'); $this->assertTrue($model->hasErrors('attr_number')); + $val = new NumberValidator(array('min' => 1)); + $model = FakedValidationModel::createWithAttributes(array('attr_num' => array(1,2,3))); + $val->validateAttribute($model, 'attr_num'); + $this->assertTrue($model->hasErrors('attr_num')); } public function testEnsureCustomMessageIsSetOnValidateAttribute() diff --git a/tests/unit/framework/validators/StringValidatorTest.php b/tests/unit/framework/validators/StringValidatorTest.php index c7d2889..8beaf16 100644 --- a/tests/unit/framework/validators/StringValidatorTest.php +++ b/tests/unit/framework/validators/StringValidatorTest.php @@ -86,6 +86,10 @@ class StringValidatorTest extends TestCase $model->attr_string = 'abc'; $val->validateAttribute($model, 'attr_string'); $this->assertTrue($model->hasErrors('attr_string')); + $val = new StringValidator(array('max' => 1)); + $model = FakedValidationModel::createWithAttributes(array('attr_str' => array('abc'))); + $val->validateAttribute($model, 'attr_str'); + $this->assertTrue($model->hasErrors('attr_str')); } public function testEnsureMessagesOnInit() diff --git a/tests/unit/framework/validators/UrlValidatorTest.php b/tests/unit/framework/validators/UrlValidatorTest.php index 7b618c1..239c92b 100644 --- a/tests/unit/framework/validators/UrlValidatorTest.php +++ b/tests/unit/framework/validators/UrlValidatorTest.php @@ -29,6 +29,12 @@ class UrlValidatorTest extends TestCase $this->assertTrue($val->validateValue('yiiframework.com')); $this->assertTrue($val->validateValue('http://yiiframework.com')); } + + public function testValidateValueWithoutScheme() + { + $val = new UrlValidator(array('pattern' => '/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)/i')); + $this->assertTrue($val->validateValue('yiiframework.com')); + } public function testValidateWithCustomScheme() {