12
12
namespace CodeIgniter \Commands ;
13
13
14
14
use CodeIgniter \Database \BaseConnection ;
15
- use CodeIgniter \Database \SQLite3 \Connection ;
15
+ use CodeIgniter \Database \Database as DatabaseFactory ;
16
+ use CodeIgniter \Database \SQLite3 \Connection as SQLite3Connection ;
16
17
use CodeIgniter \Test \CIUnitTestCase ;
17
18
use CodeIgniter \Test \Filters \CITestStreamFilter ;
18
19
use Config \Database ;
@@ -38,21 +39,24 @@ protected function setUp(): void
38
39
$ this ->connection = Database::connect ();
39
40
40
41
parent ::setUp ();
41
- }
42
42
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) {
48
44
$ file = WRITEPATH . 'foobar.db ' ;
49
-
50
45
if (file_exists ($ file )) {
51
46
unlink ($ file );
52
47
}
53
48
} 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
+ }
55
54
}
55
+ }
56
+
57
+ protected function tearDown (): void
58
+ {
59
+ stream_filter_remove ($ this ->streamFilter );
56
60
57
61
parent ::tearDown ();
58
62
}
@@ -70,7 +74,7 @@ public function testCreateDatabase()
70
74
71
75
public function testSqliteDatabaseDuplicated ()
72
76
{
73
- if (! $ this ->connection instanceof Connection ) {
77
+ if (! $ this ->connection instanceof SQLite3Connection ) {
74
78
$ this ->markTestSkipped ('Needs to run on SQLite3. ' );
75
79
}
76
80
@@ -83,7 +87,7 @@ public function testSqliteDatabaseDuplicated()
83
87
84
88
public function testOtherDriverDuplicatedDatabase ()
85
89
{
86
- if ($ this ->connection instanceof Connection ) {
90
+ if ($ this ->connection instanceof SQLite3Connection ) {
87
91
$ this ->markTestSkipped ('Needs to run on non-SQLite3 drivers. ' );
88
92
}
89
93
0 commit comments