Skip to content
Permalink
Browse files

Add test for insertMulti with id in the last spot.

Both tests work, so there are no changes to the implementation.

Closes #4048
  • Loading branch information...
markstory committed Sep 9, 2013
1 parent 2fc3222 commit 5210f831c88a54e90195dfe570bf7f92a7ec25b6
Showing with 57 additions and 0 deletions.
  1. +57 −0 lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php
@@ -1280,4 +1280,61 @@ public function testLimit() {
$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');
}
}

0 comments on commit 5210f83

Please sign in to comment.
You can’t perform that action at this time.