diff --git a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php index 546092e4a..8e5f66cb7 100644 --- a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php @@ -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 &&