1212namespace CodeIgniter \Commands ;
1313
1414use CodeIgniter \Database \BaseConnection ;
15- use CodeIgniter \Database \SQLite3 \Connection ;
15+ use CodeIgniter \Database \Database as DatabaseFactory ;
16+ use CodeIgniter \Database \SQLite3 \Connection as SQLite3Connection ;
1617use CodeIgniter \Test \CIUnitTestCase ;
1718use CodeIgniter \Test \Filters \CITestStreamFilter ;
1819use Config \Database ;
@@ -38,21 +39,24 @@ protected function setUp(): void
3839 $ this ->connection = Database::connect ();
3940
4041 parent ::setUp ();
41- }
4242
43- protected function tearDown (): void
44- {
45- stream_filter_remove ($ this ->streamFilter );
46-
47- if ($ this ->connection instanceof Connection) {
43+ if ($ this ->connection instanceof SQLite3Connection) {
4844 $ file = WRITEPATH . 'foobar.db ' ;
49-
5045 if (file_exists ($ file )) {
5146 unlink ($ file );
5247 }
5348 } else {
54- Database::forge ()->dropDatabase ('foobar ' );
49+ $ util = (new DatabaseFactory ())->loadUtils ($ this ->connection );
50+
51+ if ($ util ->databaseExists ('foobar ' )) {
52+ Database::forge ()->dropDatabase ('foobar ' );
53+ }
5554 }
55+ }
56+
57+ protected function tearDown (): void
58+ {
59+ stream_filter_remove ($ this ->streamFilter );
5660
5761 parent ::tearDown ();
5862 }
@@ -70,7 +74,7 @@ public function testCreateDatabase()
7074
7175 public function testSqliteDatabaseDuplicated ()
7276 {
73- if (! $ this ->connection instanceof Connection ) {
77+ if (! $ this ->connection instanceof SQLite3Connection ) {
7478 $ this ->markTestSkipped ('Needs to run on SQLite3. ' );
7579 }
7680
@@ -83,7 +87,7 @@ public function testSqliteDatabaseDuplicated()
8387
8488 public function testOtherDriverDuplicatedDatabase ()
8589 {
86- if ($ this ->connection instanceof Connection ) {
90+ if ($ this ->connection instanceof SQLite3Connection ) {
8791 $ this ->markTestSkipped ('Needs to run on non-SQLite3 drivers. ' );
8892 }
8993
0 commit comments