tests: Reset mwuser/pagecontent tables if necessary for postgres
authorKunal Mehta <legoktm@member.fsf.org>
Sat, 2 Jun 2018 03:31:52 +0000 (20:31 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Thu, 7 Jun 2018 03:31:57 +0000 (20:31 -0700)
As of 556c5cf464b9, postgres renames the `user` and `text` tables to
`mwuser` and `pagecontent` respectively. Have resetDB() explicitly
reset those tables when using postgres.

Bug: T195807
Change-Id: I5052dd663a4fb16389611cd2985b712fb9a15069

tests/phpunit/MediaWikiTestCase.php

index cf9dde0..61a2e67 100644 (file)
@@ -1566,6 +1566,19 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
                                $tablesUsed = array_unique( array_merge( $tablesUsed, $pageTables ) );
                        }
 
+                       // Postgres, Oracle, and MSSQL all use mwuser/pagecontent
+                       // instead of user/text. But Postgres does not remap the
+                       // table name in tableExists(), so we mark the real table
+                       // names as being used.
+                       if ( $db->getType() === 'postgres' ) {
+                               if ( in_array( 'user', $tablesUsed ) ) {
+                                       $tablesUsed[] = 'mwuser';
+                               }
+                               if ( in_array( 'text', $tablesUsed ) ) {
+                                       $tablesUsed[] = 'pagecontent';
+                               }
+                       }
+
                        $truncate = in_array( $db->getType(), [ 'oracle', 'mysql' ] );
                        foreach ( $tablesUsed as $tbl ) {
                                // TODO: reset interwiki table to its original content.