Skip to content

Commit 20a2e91

Browse files
committed
fix failing tests for mysqli - enable strict mode
1 parent bf91cad commit 20a2e91

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

tests/system/Database/Live/InsertTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,17 @@ public function testInsertBatchFailed(): void
102102
],
103103
];
104104

105-
$this->db->table('job')->insertBatch($data);
105+
$db = $this->db;
106+
107+
if ($this->db->DBDriver === 'MySQLi') {
108+
// strict mode is required for MySQLi to throw an exception here
109+
$config = config('Database');
110+
$config->tests['strictOn'] = true;
111+
112+
$db = Database::connect($config->tests);
113+
}
114+
115+
$db->table('job')->insertBatch($data);
106116
}
107117

108118
public function testReplaceWithNoMatchingData(): void

tests/system/Database/Live/TransactionTest.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,24 @@ public function testTransInsertBatchFailed(): void
254254
],
255255
];
256256

257-
$this->db->transStrict(false)->transBegin();
258-
$this->db->table('job')->insertBatch($data);
257+
$db = $this->db;
259258

260-
$this->assertFalse($this->db->transStatus());
259+
if ($this->db->DBDriver === 'MySQLi') {
260+
// strict mode is required for MySQLi to throw an exception here
261+
$config = config('Database');
262+
$config->tests['strictOn'] = true;
261263

262-
$this->db->transComplete();
264+
$db = Database::connect($config->tests);
265+
}
266+
267+
$db->transStrict(false)->transBegin();
268+
$db->table('job')->insertBatch($data);
269+
270+
$this->assertFalse($db->transStatus());
271+
272+
$db->transComplete();
273+
274+
$db->transStrict();
263275

264276
$this->dontSeeInDatabase('job', ['name' => 'Grocery Sales']);
265277
}

0 commit comments

Comments
 (0)