Skip to content

Commit d7c9ad2

Browse files
committed
test: fix setUp()
Ensure the database exists.
1 parent f1a9f3b commit d7c9ad2

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/system/Commands/CreateDatabaseTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace CodeIgniter\Commands;
1313

1414
use CodeIgniter\Database\BaseConnection;
15+
use CodeIgniter\Database\Database as DatabaseFactory;
1516
use CodeIgniter\Database\SQLite3\Connection as SQLite3Connection;
1617
use CodeIgniter\Test\CIUnitTestCase;
1718
use CodeIgniter\Test\Filters\CITestStreamFilter;
@@ -45,7 +46,11 @@ protected function setUp(): void
4546
unlink($file);
4647
}
4748
} else {
48-
Database::forge()->dropDatabase('foobar');
49+
$util = (new DatabaseFactory())->loadUtils($this->connection);
50+
51+
if ($util->databaseExists('foobar')) {
52+
Database::forge()->dropDatabase('foobar');
53+
}
4954
}
5055
}
5156

0 commit comments

Comments
 (0)