X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2FMediaWikiTestCase.php;h=91aaff523660ca3f2448594252bcb032e75b2105;hp=18e6e97d5d4a57621de94be4f4116050b337a1bc;hb=1d7a1bf8bddf0908e4f572c82268733f63126a13;hpb=15b3664ee12ac94a92d1057dab5645370276d027 diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 18e6e97d5d..91aaff5236 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -1254,7 +1254,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { * * @return Database[] Array of Database master connections */ - protected static function getExternalStoreDatabaseConnections() { global $wgDefaultExternalStore; @@ -1304,13 +1303,17 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { private function resetDB( $db, $tablesUsed ) { if ( $db ) { $userTables = [ 'user', 'user_groups', 'user_properties' ]; - $coreDBDataTables = array_merge( $userTables, [ 'page', 'revision' ] ); + $pageTables = [ 'page', 'revision', 'ip_changes', 'revision_comment_temp', 'comment' ]; + $coreDBDataTables = array_merge( $userTables, $pageTables ); - // If any of the user tables were marked as used, we should clear all of them. + // If any of the user or page tables were marked as used, we should clear all of them. if ( array_intersect( $tablesUsed, $userTables ) ) { $tablesUsed = array_unique( array_merge( $tablesUsed, $userTables ) ); TestUserRegistry::clear(); } + if ( array_intersect( $tablesUsed, $pageTables ) ) { + $tablesUsed = array_unique( array_merge( $tablesUsed, $pageTables ) ); + } $truncate = in_array( $db->getType(), [ 'oracle', 'mysql' ] ); foreach ( $tablesUsed as $tbl ) { @@ -1846,4 +1849,29 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { $this->mergeMwGlobalArrayValue( 'wgHooks', [ $hookName => [ $handler ] ] ); } + /** + * Check whether file contains given data. + * @param string $fileName + * @param string $actualData + * @param bool $createIfMissing If true, and file does not exist, create it with given data + * and skip the test. + * @param string $msg + * @since 1.30 + */ + protected function assertFileContains( + $fileName, + $actualData, + $createIfMissing = true, + $msg = '' + ) { + if ( $createIfMissing ) { + if ( !file_exists( $fileName ) ) { + file_put_contents( $fileName, $actualData ); + $this->markTestSkipped( 'Data file $fileName does not exist' ); + } + } else { + self::assertFileExists( $fileName ); + } + self::assertEquals( file_get_contents( $fileName ), $actualData, $msg ); + } }