From: Kunal Mehta Date: Sat, 2 Jun 2018 03:31:52 +0000 (-0700) Subject: tests: Reset mwuser/pagecontent tables if necessary for postgres X-Git-Tag: 1.34.0-rc.0~5163^2 X-Git-Url: http://git.cyclocoop.org/%22%22._DIR_PLUGIN_FULLCALENDAR.%22prive/themes/spip/images/event_edit.png/%22%20%20%20QUnit.url%28%7B%20filter:%20undefined%2C%20module:%20undefined%2C%20testNumber:%20undefined%20%7D%29%20%20%20%22?a=commitdiff_plain;h=fda6e09a4e6b6b16b46675bca4a808ea31a35ae7;p=lhc%2Fweb%2Fwiklou.git 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 --- 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.