Skip to content

Commit b796f0b

Browse files
committed
test: add test for type date and datetime
1 parent 02de356 commit b796f0b

1 file changed

Lines changed: 45 additions & 13 deletions

File tree

tests/system/Database/Live/UpdateTest.php

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,26 +113,58 @@ public function testUpdateWithWhereAndLimit(): void
113113

114114
public function testUpdateBatch(): void
115115
{
116+
$table = 'type_test';
117+
118+
// Prepares test data.
119+
$builder = $this->db->table($table);
120+
$builder->truncate();
121+
122+
for ($i = 0; $i < 3; $i++) {
123+
$builder->insert([
124+
'type_varchar' => 'test' . $i,
125+
'type_char' => 'char',
126+
'type_text' => 'text',
127+
'type_smallint' => 32767,
128+
'type_integer' => 2147483647,
129+
'type_bigint' => 9223372036854775807,
130+
'type_float' => 10.1,
131+
'type_numeric' => 123.23,
132+
'type_date' => '2023-12-21',
133+
'type_datetime' => '2023-12-21 12:00:00',
134+
]);
135+
}
136+
116137
$data = [
117138
[
118-
'name' => 'Derek Jones',
119-
'country' => 'Greece',
139+
'type_varchar' => 'test1',
140+
'type_text' => 'updated',
141+
'type_bigint' => 9999999,
142+
'type_date' => '2024-01-01',
143+
'type_datetime' => '2024-01-01 09:00:00',
120144
],
121145
[
122-
'name' => 'Ahmadinejad',
123-
'country' => 'Greece',
146+
'type_varchar' => 'test2',
147+
'type_text' => 'updated',
148+
'type_bigint' => 9999999,
149+
'type_date' => '2024-01-01',
150+
'type_datetime' => '2024-01-01 09:00:00',
124151
],
125152
];
126-
127-
$this->db->table('user')->updateBatch($data, 'name');
128-
129-
$this->seeInDatabase('user', [
130-
'name' => 'Derek Jones',
131-
'country' => 'Greece',
153+
$this->db->table($table)->updateBatch($data, 'type_varchar');
154+
155+
$this->seeInDatabase($table, [
156+
'type_varchar' => 'test1',
157+
'type_text' => 'updated',
158+
'type_bigint' => 9999999,
159+
'type_date' => '2024-01-01',
160+
'type_datetime' => '2024-01-01 09:00:00',
132161
]);
133-
$this->seeInDatabase('user', [
134-
'name' => 'Ahmadinejad',
135-
'country' => 'Greece',
162+
$this->seeInDatabase($table, [
163+
'type_varchar' => 'test2',
164+
'type_text' => 'updated',
165+
'type_bigint' => 9999999,
166+
'type_date' => '2024-01-01',
167+
'type_datetime' => '2024-01-01 09:00:00',
136168
]);
137169
}
138170

0 commit comments

Comments
 (0)