@@ -54,40 +54,89 @@ public function testCreateDatabase(): void
5454 if ($ this ->db ->DBDriver === 'OCI8 ' ) {
5555 $ this ->markTestSkipped ('OCI8 does not support create database. ' );
5656 }
57+
5758 $ databaseCreated = $ this ->forge ->createDatabase ('test_forge_database ' );
5859
5960 $ this ->assertTrue ($ databaseCreated );
6061 }
6162
63+ public function testCreateDatabaseWithDots (): void
64+ {
65+ if ($ this ->db ->DBDriver === 'OCI8 ' ) {
66+ $ this ->markTestSkipped ('OCI8 does not support create database. ' );
67+ }
68+
69+ $ dbName = 'test_com.sitedb.web ' ;
70+
71+ $ databaseCreated = $ this ->forge ->createDatabase ($ dbName );
72+
73+ $ this ->assertTrue ($ databaseCreated );
74+
75+ // Checks if tableExists() works.
76+ $ config = config (Database::class)->{$ this ->DBGroup };
77+ $ config ['database ' ] = $ dbName ;
78+ $ db = db_connect ($ config );
79+ $ result = $ db ->tableExists ('not_exist ' );
80+
81+ $ this ->assertFalse ($ result );
82+
83+ $ db ->close ();
84+ if ($ this ->db ->DBDriver !== 'SQLite3 ' ) {
85+ $ this ->forge ->dropDatabase ($ dbName );
86+ }
87+ }
88+
6289 public function testCreateDatabaseIfNotExists (): void
6390 {
6491 if ($ this ->db ->DBDriver === 'OCI8 ' ) {
6592 $ this ->markTestSkipped ('OCI8 does not support create database. ' );
6693 }
94+
6795 $ dbName = 'test_forge_database_exist ' ;
6896
6997 $ databaseCreateIfNotExists = $ this ->forge ->createDatabase ($ dbName , true );
98+
99+ $ this ->assertTrue ($ databaseCreateIfNotExists );
100+
70101 if ($ this ->db ->DBDriver !== 'SQLite3 ' ) {
71102 $ this ->forge ->dropDatabase ($ dbName );
72103 }
73-
74- $ this ->assertTrue ($ databaseCreateIfNotExists );
75104 }
76105
77106 public function testCreateDatabaseIfNotExistsWithDb (): void
78107 {
79108 if ($ this ->db ->DBDriver === 'OCI8 ' ) {
80109 $ this ->markTestSkipped ('OCI8 does not support create database. ' );
81110 }
111+
82112 $ dbName = 'test_forge_database_exist ' ;
83113
84114 $ this ->forge ->createDatabase ($ dbName );
85115 $ databaseExists = $ this ->forge ->createDatabase ($ dbName , true );
116+
117+ $ this ->assertTrue ($ databaseExists );
118+
86119 if ($ this ->db ->DBDriver !== 'SQLite3 ' ) {
87120 $ this ->forge ->dropDatabase ($ dbName );
88121 }
122+ }
123+
124+ public function testCreateDatabaseIfNotExistsWithDbWithDots (): void
125+ {
126+ if ($ this ->db ->DBDriver === 'OCI8 ' ) {
127+ $ this ->markTestSkipped ('OCI8 does not support create database. ' );
128+ }
129+
130+ $ dbName = 'test_forge.database.exist ' ;
131+
132+ $ this ->forge ->createDatabase ($ dbName );
133+ $ databaseExists = $ this ->forge ->createDatabase ($ dbName , true );
89134
90135 $ this ->assertTrue ($ databaseExists );
136+
137+ if ($ this ->db ->DBDriver !== 'SQLite3 ' ) {
138+ $ this ->forge ->dropDatabase ($ dbName );
139+ }
91140 }
92141
93142 public function testDropDatabase (): void
@@ -106,17 +155,14 @@ public function testDropDatabase(): void
106155
107156 public function testCreateDatabaseExceptionNoCreateStatement (): void
108157 {
109- $ this ->setPrivateProperty ($ this ->forge , 'createDatabaseStr ' , false );
158+ if ($ this ->db ->DBDriver !== 'OCI8 ' ) {
159+ $ this ->markTestSkipped ($ this ->db ->DBDriver . ' does support drop database. ' );
160+ }
110161
111- if ($ this ->db ->DBDriver === 'SQLite3 ' ) {
112- $ databaseCreated = $ this ->forge ->createDatabase ('test_forge_database ' );
113- $ this ->assertTrue ($ databaseCreated );
114- } else {
115- $ this ->expectException (DatabaseException::class);
116- $ this ->expectExceptionMessage ('This feature is not available for the database you are using. ' );
162+ $ this ->expectException (DatabaseException::class);
163+ $ this ->expectExceptionMessage ('This feature is not available for the database you are using. ' );
117164
118- $ this ->forge ->createDatabase ('test_forge_database ' );
119- }
165+ $ this ->forge ->createDatabase ('test_forge_database ' );
120166 }
121167
122168 public function testDropDatabaseExceptionNoDropStatement (): void
0 commit comments