Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Clearer error message

  • Loading branch information...
commit 1201887ad1e31aef01529bbb5dc3b056186015c0 1 parent cfa1045
@dereuromark dereuromark authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/Cake/TestSuite/Fixture/CakeTestFixture.php
View
8 lib/Cake/TestSuite/Fixture/CakeTestFixture.php
@@ -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)) {
@@ -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 &&
Please sign in to comment.
Something went wrong with that request. Please try again.