Skip to content

Commit

Permalink
Clearer error message
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark committed Jan 6, 2014
1 parent cfa1045 commit 1201887
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Cake/TestSuite/Fixture/CakeTestFixture.php
Expand Up @@ -265,6 +265,7 @@ public function drop($db) {
*
* @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)) {
Expand All @@ -277,10 +278,15 @@ public function insert($db) {
$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 &&
Expand Down

0 comments on commit 1201887

Please sign in to comment.