Exemplo n.º 1
0
 public function testValidateNonDatabaseAttribute()
 {
     $val = new UniqueValidator(['targetClass' => ValidatorTestRefModel::className(), 'targetAttribute' => 'ref']);
     $m = ValidatorTestMainModel::findOne(1);
     $val->validateAttribute($m, 'testMainVal');
     $this->assertFalse($m->hasErrors('testMainVal'));
     $m = ValidatorTestMainModel::findOne(1);
     $m->testMainVal = 4;
     $val->validateAttribute($m, 'testMainVal');
     $this->assertTrue($m->hasErrors('testMainVal'));
 }