Clearer error message

This commit is contained in:
euromark 2014-01-06 20:42:17 +01:00
parent cfa104577f
commit 1201887ad1

View file

@ -265,6 +265,7 @@ class CakeTestFixture {
*
* @param DboSource $db An instance of the database into which the records will be inserted
* @return boolean on success or if there are no records to insert, or false on failure
* @throws CakeException if count of values and fields does not match.
*/
public function insert($db) {
if (!isset($this->_insert)) {
@ -277,10 +278,15 @@ class CakeTestFixture {
$fields = array_unique($fields);
$default = array_fill_keys($fields, null);
foreach ($this->records as $record) {
$values[] = array_values(array_merge($default, $record));
$merge = array_values(array_merge($default, $record));
if (count($fields) !== count($merge)) {
throw new CakeException('Fixure invalid: Count of fields does not match count of values');
}
$values[] = $merge;
}
$nested = $db->useNestedTransactions;
$db->useNestedTransactions = false;
$result = $db->insertMulti($this->table, $fields, $values);
if (
$this->primaryKey &&