From 964a86a7d08e5cc07bb75ced6e15005772423452 Mon Sep 17 00:00:00 2001 From: MGatner Date: Thu, 12 Nov 2020 15:26:09 +0000 Subject: [PATCH] Add insert batch timestamps tests --- tests/system/Database/Live/ModelTest.php | 46 ++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/system/Database/Live/ModelTest.php b/tests/system/Database/Live/ModelTest.php index f79dc2d3df9f..ecb2f9ab7391 100644 --- a/tests/system/Database/Live/ModelTest.php +++ b/tests/system/Database/Live/ModelTest.php @@ -1392,6 +1392,52 @@ public function testInsertBatchValidationFail() //-------------------------------------------------------------------- + public function testInsertBatchSetsIntTimestamps() + { + $job_data = [ + [ + 'name' => 'Philosopher', + ], + [ + 'name' => 'Laborer', + ], + ]; + + $model = new JobModel($this->db); + $this->setPrivateProperty($model, 'useTimestamps', true); + $this->assertEquals(2, $model->insertBatch($job_data)); + + $result = $model->where('name', 'Philosopher')->first(); + + $this->assertEquals(time(), $result->created_at); + } + + public function testInsertBatchSetsDatetimeTimestamps() + { + $user_data = [ + [ + 'name' => 'Lou', + 'email' => 'lou@example.com', + 'country' => 'Ireland', + ], + [ + 'name' => 'Sue', + 'email' => 'sue@example.com', + 'country' => 'Ireland', + ], + ]; + + $model = new UserModel($this->db); + $this->setPrivateProperty($model, 'useTimestamps', true); + $this->assertEquals(2, $model->insertBatch($user_data)); + + $result = $model->where('name', 'Lou')->first(); + + $this->assertEquals(time(), strtotime($result->created_at)); + } + + //-------------------------------------------------------------------- + public function testUpdateBatchSuccess() { $data = [