Skip to content

Commit f1a9f3b

Browse files
committed
test: fix setUp()
Drop database for non-SQLite connections.
1 parent 4de1831 commit f1a9f3b

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

tests/system/Commands/CreateDatabaseTest.php

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

1414
use CodeIgniter\Database\BaseConnection;
15-
use CodeIgniter\Database\SQLite3\Connection;
15+
use CodeIgniter\Database\SQLite3\Connection as SQLite3Connection;
1616
use CodeIgniter\Test\CIUnitTestCase;
1717
use CodeIgniter\Test\Filters\CITestStreamFilter;
1818
use Config\Database;
@@ -39,9 +39,13 @@ protected function setUp(): void
3939

4040
parent::setUp();
4141

42-
$file = WRITEPATH . 'foobar.db';
43-
if (file_exists($file)) {
44-
unlink($file);
42+
if ($this->connection instanceof SQLite3Connection) {
43+
$file = WRITEPATH . 'foobar.db';
44+
if (file_exists($file)) {
45+
unlink($file);
46+
}
47+
} else {
48+
Database::forge()->dropDatabase('foobar');
4549
}
4650
}
4751

@@ -65,7 +69,7 @@ public function testCreateDatabase()
6569

6670
public function testSqliteDatabaseDuplicated()
6771
{
68-
if (! $this->connection instanceof Connection) {
72+
if (! $this->connection instanceof SQLite3Connection) {
6973
$this->markTestSkipped('Needs to run on SQLite3.');
7074
}
7175

@@ -78,7 +82,7 @@ public function testSqliteDatabaseDuplicated()
7882

7983
public function testOtherDriverDuplicatedDatabase()
8084
{
81-
if ($this->connection instanceof Connection) {
85+
if ($this->connection instanceof SQLite3Connection) {
8286
$this->markTestSkipped('Needs to run on non-SQLite3 drivers.');
8387
}
8488

0 commit comments

Comments
 (0)