From 5210f831c88a54e90195dfe570bf7f92a7ec25b6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 9 Sep 2013 19:43:15 -0400 Subject: [PATCH] Add test for insertMulti with id in the last spot. Both tests work, so there are no changes to the implementation. Closes #4048 --- .../Case/Model/Datasource/DboSourceTest.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php index 6604aef76..dc1e47434 100644 --- a/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php @@ -1280,4 +1280,61 @@ class DboSourceTest extends CakeTestCase { $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'); + } }