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

test: update testInsertBatch() to use various data types #8450

Merged
merged 1 commit into from
Jan 25, 2024
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
34 changes: 26 additions & 8 deletions tests/system/Database/Live/InsertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,41 @@
$this->seeInDatabase('job', ['name' => 'Grocery Sales']);
}

public function testInsertBatch(): void

Check warning on line 50 in tests/system/Database/Live/InsertTest.php

View workflow job for this annotation

GitHub Actions / DatabaseLive (8.1, OCI8, 8.0) / tests

Took 1.21s from 0.50s limit to run CodeIgniter\\Database\\Live\\InsertTest::testInsertBatch
{
$jobData = [
$table = 'type_test';

$builder = $this->db->table($table);
$builder->truncate();

$data = [
[
'name' => 'Comedian',
'description' => 'Theres something in your teeth',
'type_varchar' => 'test1',
'type_char' => 'char',
'type_smallint' => 32767,
'type_integer' => 2_147_483_647,
'type_bigint' => 9_223_372_036_854_775_807,
'type_numeric' => 123.23,
'type_date' => '2023-12-01',
'type_datetime' => '2023-12-21 12:00:00',
],
[
'name' => 'Cab Driver',
'description' => 'Iam yellow',
'type_varchar' => 'test2',
'type_char' => 'char',
'type_smallint' => 32767,
'type_integer' => 2_147_483_647,
'type_bigint' => 9_223_372_036_854_775_807,
'type_numeric' => 123.23,
'type_date' => '2023-12-02',
'type_datetime' => '2023-12-21 12:00:00',
],
];

$this->db->table('job')->insertBatch($jobData);
$this->db->table($table)->insertBatch($data);

$this->seeInDatabase('job', ['name' => 'Comedian']);
$this->seeInDatabase('job', ['name' => 'Cab Driver']);
$expected = $data;
$this->seeInDatabase($table, $expected[0]);
$this->seeInDatabase($table, $expected[1]);
}

public function testReplaceWithNoMatchingData(): void
Expand Down
Loading