Skip to content

Commit d9f5c01

Browse files
authored
Validation errors for haveRecord method
When haveRecord is used and it fails to create a model due to some validation, it's not obvious from the test output why. The proposed fix will append default failure message with associated validation errors
1 parent 69d0e99 commit d9f5c01

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Codeception/Module/Yii2.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ public function haveRecord($model, $attributes = [])
574574
$record->setAttributes($attributes, false);
575575
$res = $record->save(false);
576576
if (!$res) {
577-
$this->fail("Record $model was not saved");
577+
$this->fail("Record $model was not saved: " . \yii\helpers\Json::encode($record->errors));
578578
}
579579
return $record->primaryKey;
580580
}

0 commit comments

Comments
 (0)