Skip to content

Commit

Permalink
fix failing tests for mysqli - enable strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsn committed Jan 2, 2025
1 parent bf91cad commit 20a2e91
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
12 changes: 11 additions & 1 deletion tests/system/Database/Live/InsertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,17 @@ public function testInsertBatchFailed(): void
],
];

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

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

$db = Database::connect($config->tests);
}

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

public function testReplaceWithNoMatchingData(): void
Expand Down
20 changes: 16 additions & 4 deletions tests/system/Database/Live/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,24 @@ public function testTransInsertBatchFailed(): void
],
];

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

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

$this->db->transComplete();
$db = Database::connect($config->tests);
}

$db->transStrict(false)->transBegin();
$db->table('job')->insertBatch($data);

$this->assertFalse($db->transStatus());

$db->transComplete();

$db->transStrict();

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

0 comments on commit 20a2e91

Please sign in to comment.