Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add insert batch timestamps tests #3879

Merged
merged 1 commit into from
Nov 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions tests/system/Database/Live/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '[email protected]',
'country' => 'Ireland',
],
[
'name' => 'Sue',
'email' => '[email protected]',
'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 = [
Expand Down