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:
mark_story 2013-09-09 19:43:15 -04:00
parent 2fc3222322
commit 5210f831c8

View file

@ -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');
}
} }