From fda6e09a4e6b6b16b46675bca4a808ea31a35ae7 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Fri, 1 Jun 2018 20:31:52 -0700 Subject: [PATCH] tests: Reset mwuser/pagecontent tables if necessary for postgres 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index cf9dde0160..61a2e67375 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -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. -- 2.20.1