@@ -245,7 +245,7 @@ public function test_getColumns(): void
245245 ], Arr::first ($ sb ->getColumns ($ table )));
246246 }
247247
248- public function test_getAllTables (): void
248+ public function test_getTableListing (): void
249249 {
250250 $ conn = $ this ->getDefaultConnection ();
251251 $ sb = $ conn ->getSchemaBuilder ();
@@ -256,14 +256,53 @@ public function test_getAllTables(): void
256256 $ table ->primary ('id ' );
257257 });
258258
259- /** @var array{ name: string, type: string } $row */
260- $ row = Arr::first (
261- $ sb ->getTables (),
262- static fn (array $ row ): bool => $ row ['name ' ] === $ table ,
263- );
259+ $ this ->assertContains ($ table , $ sb ->getTableListing ());
260+ }
264261
265- $ this ->assertSame ($ table , $ row ['name ' ]);
266- $ this ->assertSame ('BASE TABLE ' , $ row ['type ' ]);
262+ public function test_getIndexes (): void
263+ {
264+ $ conn = $ this ->getDefaultConnection ();
265+ $ sb = $ conn ->getSchemaBuilder ();
266+ $ table = $ this ->generateTableName (class_basename (__CLASS__ ));
267+ $ sb ->create ($ table , function (Blueprint $ table ) {
268+ $ table ->uuid ('id ' )->primary ();
269+ $ table ->uuid ('something ' );
270+ $ table ->index ('something ' );
271+ });
272+
273+ $ this ->assertSame ([
274+ [
275+ 'name ' => strtolower ($ table ) . '_something_index ' ,
276+ 'columns ' => ['something ' ],
277+ 'type ' => 'index ' ,
278+ 'unique ' => false ,
279+ 'primary ' => false ,
280+ ],
281+ [
282+ 'name ' => 'PRIMARY_KEY ' ,
283+ 'columns ' => ['id ' ],
284+ 'type ' => 'primary_key ' ,
285+ 'unique ' => true ,
286+ 'primary ' => true ,
287+ ],
288+ ], $ sb ->getIndexes ($ table ));
289+ }
290+
291+ public function test_getIndexListing (): void
292+ {
293+ $ conn = $ this ->getDefaultConnection ();
294+ $ sb = $ conn ->getSchemaBuilder ();
295+ $ table = $ this ->generateTableName (class_basename (__CLASS__ ));
296+ $ sb ->create ($ table , function (Blueprint $ table ) {
297+ $ table ->uuid ('id ' )->primary ();
298+ $ table ->uuid ('something ' );
299+ $ table ->index ('something ' );
300+ });
301+
302+ $ this ->assertSame ([
303+ strtolower ($ table ) . '_something_index ' ,
304+ 'PRIMARY_KEY ' ,
305+ ], $ sb ->getIndexListing ($ table ));
267306 }
268307
269308 public function test_dropAllTables (): void
0 commit comments