mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Clearer error message
This commit is contained in:
parent
cfa104577f
commit
1201887ad1
1 changed files with 7 additions and 1 deletions
|
@ -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 &&
|
||||
|
|
Loading…
Reference in a new issue