Skip to content

Commit 88547ad

Browse files
authored
Merge pull request #8450 from kenjis/test-postgre-qb-InsertBatch
test: update testInsertBatch() to use various data types
2 parents 5fd5f63 + 63ab12b commit 88547ad

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

tests/system/Database/Live/InsertTest.php

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,39 @@ public function testInsert(): void
4949

5050
public function testInsertBatch(): void
5151
{
52-
$jobData = [
52+
$table = 'type_test';
53+
54+
$builder = $this->db->table($table);
55+
$builder->truncate();
56+
57+
$data = [
5358
[
54-
'name' => 'Comedian',
55-
'description' => 'Theres something in your teeth',
59+
'type_varchar' => 'test1',
60+
'type_char' => 'char',
61+
'type_smallint' => 32767,
62+
'type_integer' => 2_147_483_647,
63+
'type_bigint' => 9_223_372_036_854_775_807,
64+
'type_numeric' => 123.23,
65+
'type_date' => '2023-12-01',
66+
'type_datetime' => '2023-12-21 12:00:00',
5667
],
5768
[
58-
'name' => 'Cab Driver',
59-
'description' => 'Iam yellow',
69+
'type_varchar' => 'test2',
70+
'type_char' => 'char',
71+
'type_smallint' => 32767,
72+
'type_integer' => 2_147_483_647,
73+
'type_bigint' => 9_223_372_036_854_775_807,
74+
'type_numeric' => 123.23,
75+
'type_date' => '2023-12-02',
76+
'type_datetime' => '2023-12-21 12:00:00',
6077
],
6178
];
6279

63-
$this->db->table('job')->insertBatch($jobData);
80+
$this->db->table($table)->insertBatch($data);
6481

65-
$this->seeInDatabase('job', ['name' => 'Comedian']);
66-
$this->seeInDatabase('job', ['name' => 'Cab Driver']);
82+
$expected = $data;
83+
$this->seeInDatabase($table, $expected[0]);
84+
$this->seeInDatabase($table, $expected[1]);
6785
}
6886

6987
public function testReplaceWithNoMatchingData(): void

0 commit comments

Comments
 (0)