mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Add test for insertMulti with id in the last spot.
Both tests work, so there are no changes to the implementation. Closes #4048
This commit is contained in:
parent
2fc3222322
commit
5210f831c8
1 changed files with 57 additions and 0 deletions
|
@ -1280,4 +1280,61 @@ class DboSourceTest extends CakeTestCase {
|
||||||
$this->assertNotContains($scientificNotation, $result);
|
$this->assertNotContains($scientificNotation, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test insertMulti with id position.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testInsertMultiId() {
|
||||||
|
$this->loadFixtures('Article');
|
||||||
|
$Article = ClassRegistry::init('Article');
|
||||||
|
$db = $Article->getDatasource();
|
||||||
|
$datetime = date('Y-m-d H:i:s');
|
||||||
|
$data = array(
|
||||||
|
array(
|
||||||
|
'user_id' => 1,
|
||||||
|
'title' => 'test',
|
||||||
|
'body' => 'test',
|
||||||
|
'published' => 'N',
|
||||||
|
'created' => $datetime,
|
||||||
|
'updated' => $datetime,
|
||||||
|
'id' => 100,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'user_id' => 1,
|
||||||
|
'title' => 'test 101',
|
||||||
|
'body' => 'test 101',
|
||||||
|
'published' => 'N',
|
||||||
|
'created' => $datetime,
|
||||||
|
'updated' => $datetime,
|
||||||
|
'id' => 101,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$result = $db->insertMulti('articles', array_keys($data[0]), $data);
|
||||||
|
$this->assertTrue($result, 'Data was saved');
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
array(
|
||||||
|
'id' => 102,
|
||||||
|
'user_id' => 1,
|
||||||
|
'title' => 'test',
|
||||||
|
'body' => 'test',
|
||||||
|
'published' => 'N',
|
||||||
|
'created' => $datetime,
|
||||||
|
'updated' => $datetime,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'id' => 103,
|
||||||
|
'user_id' => 1,
|
||||||
|
'title' => 'test 101',
|
||||||
|
'body' => 'test 101',
|
||||||
|
'published' => 'N',
|
||||||
|
'created' => $datetime,
|
||||||
|
'updated' => $datetime,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = $db->insertMulti('articles', array_keys($data[0]), $data);
|
||||||
|
$this->assertTrue($result, 'Data was saved');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue