@@ -187,23 +187,67 @@ public function testCreateInterleavedTable(): void
187
187
$ this ->assertTrue ($ sb ->hasTable (self ::TABLE_NAME_RELATION_CHILD_INTERLEAVED ));
188
188
}
189
189
190
+ public function test_getTables (): void
191
+ {
192
+ $ conn = $ this ->getDefaultConnection ();
193
+ $ sb = $ conn ->getSchemaBuilder ();
194
+ $ table = $ this ->generateTableName (class_basename (__CLASS__ ));
195
+
196
+ $ sb ->create ($ table , function (Blueprint $ table ) {
197
+ $ table ->uuid ('id ' );
198
+ $ table ->primary ('id ' );
199
+ });
200
+
201
+ /** @var array{ name: string, type: string } $row */
202
+ $ row = Arr::first (
203
+ $ sb ->getTables (),
204
+ static fn (array $ row ): bool => $ row ['name ' ] === $ table ,
205
+ );
206
+
207
+ $ this ->assertSame ($ table , $ row ['name ' ]);
208
+ }
209
+
210
+ public function test_getColumns (): void
211
+ {
212
+ $ conn = $ this ->getDefaultConnection ();
213
+ $ sb = $ conn ->getSchemaBuilder ();
214
+ $ table = $ this ->generateTableName (class_basename (__CLASS__ ));
215
+
216
+ $ sb ->create ($ table , function (Blueprint $ table ) {
217
+ $ table ->uuid ('id ' );
218
+ $ table ->primary ('id ' );
219
+ });
220
+
221
+ $ this ->assertSame ([
222
+ 'name ' => 'id ' ,
223
+ 'type_name ' => 'STRING ' ,
224
+ 'type ' => 'STRING(36) ' ,
225
+ 'collation ' => null ,
226
+ 'nullable ' => false ,
227
+ 'default ' => null ,
228
+ 'auto_increment ' => false ,
229
+ 'comment ' => null ,
230
+ ], Arr::first ($ sb ->getColumns ($ table )));
231
+ }
232
+
190
233
public function test_getAllTables (): void
191
234
{
192
235
$ conn = $ this ->getDefaultConnection ();
193
236
$ sb = $ conn ->getSchemaBuilder ();
237
+ $ table = $ this ->generateTableName (class_basename (__CLASS__ ));
194
238
195
- $ sb ->create (self :: TABLE_NAME_CREATED , function (Blueprint $ table ) {
239
+ $ sb ->create ($ table , function (Blueprint $ table ) {
196
240
$ table ->uuid ('id ' );
197
241
$ table ->primary ('id ' );
198
242
});
199
243
200
244
/** @var array{ name: string, type: string } $row */
201
245
$ row = Arr::first (
202
246
$ sb ->getAllTables (),
203
- static fn (array $ row ): bool => $ row ['name ' ] === self :: TABLE_NAME_CREATED ,
247
+ static fn (array $ row ): bool => $ row ['name ' ] === $ table ,
204
248
);
205
249
206
- $ this ->assertSame (self :: TABLE_NAME_CREATED , $ row ['name ' ]);
250
+ $ this ->assertSame ($ table , $ row ['name ' ]);
207
251
$ this ->assertSame ('BASE TABLE ' , $ row ['type ' ]);
208
252
}
209
253
}
0 commit comments