1717use CodeIgniter \Test \CIUnitTestCase ;
1818use CodeIgniter \Test \DatabaseTestTrait ;
1919use CodeIgniter \Test \Mock \MockInputOutput ;
20+ use Config \Database ;
2021use PHPUnit \Framework \Attributes \Group ;
2122
2223/**
@@ -51,12 +52,16 @@ protected function tearDown(): void
5152
5253 public function testDbTableWithInputs (): void
5354 {
55+ $ tableIndex = array_search ('db_migrations ' , Database::connect ()->listTables (), true );
56+
57+ $ this ->assertIsInt ($ tableIndex );
58+
5459 // Set MockInputOutput to CLI.
5560 $ io = new MockInputOutput ();
5661 CLI ::setInputOutput ($ io );
5762
58- // User will input "a" (invalid value) and "0" .
59- $ io ->setInputs (['a ' , ' 0 ' ]);
63+ // User will input "a" (invalid value) and then select db_migrations .
64+ $ io ->setInputs (['a ' , ( string ) $ tableIndex ]);
6065
6166 command ('db:table ' );
6267
@@ -71,7 +76,7 @@ public function testDbTableWithInputs(): void
7176 $ result ,
7277 );
7378 $ this ->assertMatchesRegularExpression (
74- '/Which table do you want to see\? \[[\d,\s]+\]\: 0 / ' ,
79+ '/Which table do you want to see\? \[[\d,\s]+\]\: ' . $ tableIndex . ' / ' ,
7580 $ result ,
7681 );
7782 $ this ->assertMatchesRegularExpression (
0 commit comments