|
|
@ -97,6 +97,13 @@ abstract class ExistValidatorTest extends DatabaseTestCase |
|
|
|
$m->test_val = [2, 3, 4, 5]; |
|
|
|
$m->test_val = [2, 3, 4, 5]; |
|
|
|
$val->validateAttribute($m, 'test_val'); |
|
|
|
$val->validateAttribute($m, 'test_val'); |
|
|
|
$this->assertFalse($m->hasErrors('test_val')); |
|
|
|
$this->assertFalse($m->hasErrors('test_val')); |
|
|
|
|
|
|
|
// existing non-unique array |
|
|
|
|
|
|
|
$val = new ExistValidator(['targetAttribute' => 'ref']); |
|
|
|
|
|
|
|
$val->allowArray = true; |
|
|
|
|
|
|
|
$m = new ValidatorTestRefModel(); |
|
|
|
|
|
|
|
$m->test_val = [2, 2, 3, 3, 4, 4, 5, 5]; |
|
|
|
|
|
|
|
$val->validateAttribute($m, 'test_val'); |
|
|
|
|
|
|
|
$this->assertFalse($m->hasErrors('test_val')); |
|
|
|
// non-existing array |
|
|
|
// non-existing array |
|
|
|
$val = new ExistValidator(['targetAttribute' => 'ref']); |
|
|
|
$val = new ExistValidator(['targetAttribute' => 'ref']); |
|
|
|
$val->allowArray = true; |
|
|
|
$val->allowArray = true; |
|
|
|