public function testIfWillPreventSaveOfDocumentIfNotValid() { $model = new DocumentWithRequiredValidator(); $saved = $model->save(); $this->assertFalse($saved); $model->login = '******'; $saved2 = $model->save(); $this->assertTrue($saved2); }
public function testIfWillSetErrorsWithExternalValidatorCallToDocumentInstance() { $model = new DocumentWithRequiredValidator(); $validator = new Validator($model); // Should not pass validation $this->assertFalse($validator->validate()); $errors = $model->getErrors(); codecept_debug('Error message is: ' . $errors['login'][0]); $this->assertGreaterThan(0, count($errors)); $this->assertSame(1, count($errors['login'])); $this->assertTrue(is_string($errors['login'][0])); }