Skip to content

Commit 24d5a44

Browse files
committed
test(Database): Fix PostgreSQL random order test failures
1 parent cd8f5dc commit 24d5a44

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎tests/system/Database/Live/ForgeTest.php‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ public function testCreateDatabase(): void
8888
$this->markTestSkipped('OCI8 does not support create database.');
8989
}
9090

91+
try {
92+
$this->forge->dropDatabase('test_forge_database');
93+
} catch (DatabaseException $e) {
94+
// Ignore if doesn't exist
95+
}
96+
9197
$databaseCreated = $this->forge->createDatabase('test_forge_database');
9298

9399
$this->assertTrue($databaseCreated);
@@ -101,6 +107,12 @@ public function testCreateDatabaseWithDots(): void
101107

102108
$dbName = 'test_com.sitedb.web';
103109

110+
try {
111+
$this->forge->dropDatabase($dbName);
112+
} catch (DatabaseException $e) {
113+
// Ignore if doesn't exist
114+
}
115+
104116
$databaseCreated = $this->forge->createDatabase($dbName);
105117

106118
$this->assertTrue($databaseCreated);
@@ -184,6 +196,12 @@ public function testDropDatabase(): void
184196
$this->markTestSkipped('SQLite3 requires file path to drop database');
185197
}
186198

199+
try {
200+
$this->forge->createDatabase('test_forge_database');
201+
} catch (DatabaseException $e) {
202+
// Ignore if exists
203+
}
204+
187205
$databaseDropped = $this->forge->dropDatabase('test_forge_database');
188206

189207
$this->assertTrue($databaseDropped);

‎tests/system/Database/Live/Postgre/ConnectTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testShowErrorMessageWhenSettingInvalidCharset(): void
4747
$group = $config->tests;
4848
// Sets invalid charset.
4949
$group['charset'] = 'utf8mb4';
50-
$db = Database::connect($group);
50+
$db = Database::connect($group, false);
5151

5252
// Actually connect to DB.
5353
$db->initialize();

0 commit comments

Comments
 (0)