File tree Expand file tree Collapse file tree
tests/system/Database/Live Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1684,9 +1684,11 @@ protected function getDriverFunctionPrefix(): string
16841684 public function listTables (bool $ constrainByPrefix = false )
16851685 {
16861686 if (isset ($ this ->dataCache ['table_names ' ]) && $ this ->dataCache ['table_names ' ]) {
1687- return $ constrainByPrefix
1687+ $ tables = $ constrainByPrefix
16881688 ? preg_grep ("/^ {$ this ->DBPrefix }/ " , $ this ->dataCache ['table_names ' ])
16891689 : $ this ->dataCache ['table_names ' ];
1690+
1691+ return array_values ($ tables );
16901692 }
16911693
16921694 $ sql = $ this ->_listTables ($ constrainByPrefix );
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ private function dropExtraneousTable(): void
7878 $ oldPrefix = $ this ->db ->getPrefix ();
7979 $ this ->db ->setPrefix ('tmp_ ' );
8080
81- Database::forge ($ this ->DBGroup )->dropTable ('widgets ' );
81+ Database::forge ($ this ->DBGroup )->dropTable ('widgets ' , true );
8282
8383 $ this ->db ->setPrefix ($ oldPrefix );
8484 }
@@ -139,4 +139,22 @@ public function testListTablesConstrainedByExtraneousPrefixReturnsOnlyTheExtrane
139139 $ this ->dropExtraneousTable ();
140140 }
141141 }
142+
143+ public function testListTablesReturnsListAfterCachedTableIsDropped (): void
144+ {
145+ try {
146+ $ this ->createExtraneousTable ();
147+
148+ $ tables = $ this ->db ->listTables ();
149+ $ this ->assertSame (array_values ($ tables ), $ tables );
150+
151+ $ this ->dropExtraneousTable ();
152+
153+ $ tables = $ this ->db ->listTables ();
154+ $ this ->assertSame (array_values ($ tables ), $ tables );
155+ $ this ->assertNotContains ('tmp_widgets ' , $ tables );
156+ } finally {
157+ $ this ->dropExtraneousTable ();
158+ }
159+ }
142160}
You can’t perform that action at this time.
0 commit comments