Skip to content

Commit 18aa080

Browse files
committed
test: add tests
1 parent 6eb8f72 commit 18aa080

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/system/Database/Live/TransactionDBDebugTrueTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public function testTransStart()
7979

8080
$this->db->transComplete();
8181

82+
$this->assertFalse($this->db->transStatus());
8283
$this->dontSeeInDatabase('job', ['name' => 'Grocery Sales']);
8384
}
8485

@@ -204,4 +205,31 @@ public function testTransStrictFalse()
204205

205206
$this->seeInDatabase('job', ['name' => 'Comedian']);
206207
}
208+
209+
public function testTransBegin()
210+
{
211+
$builder = $this->db->table('job');
212+
213+
$this->db->transBegin();
214+
215+
$jobData = [
216+
'name' => 'Grocery Sales',
217+
'description' => 'Discount!',
218+
];
219+
$builder->insert($jobData);
220+
221+
// Duplicate entry '1' for key 'PRIMARY'
222+
$jobData = [
223+
'id' => 1,
224+
'name' => 'Comedian',
225+
'description' => 'Theres something in your teeth',
226+
];
227+
$builder->insert($jobData);
228+
229+
$this->assertFalse($this->db->transStatus());
230+
231+
$this->db->transRollback();
232+
233+
$this->dontSeeInDatabase('job', ['name' => 'Grocery Sales']);
234+
}
207235
}

0 commit comments

Comments
 (0)