X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2FMediaWikiTestCase.php;h=13d09ab4ee701ae48c706d650c9ed6604f7629fc;hp=ed6479c8dccd3684ebd0d7d29cc8f4189a1fc8c3;hb=b34260f3794623f34b069aa524c7189c9f8d8d8d;hpb=6f680554ceb988f3895184167d5006d722a0afb3 diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index ed6479c8dc..13d09ab4ee 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -14,9 +14,10 @@ use Wikimedia\TestingAccessWrapper; /** * @since 1.18 */ -abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { +abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { use MediaWikiCoversValidator; + use PHPUnit4And6Compat; /** * The service locator created by prepareServices(). This service locator will @@ -260,20 +261,19 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { * which we can't allow, as that would open a new connection for mysql. * Replace with a HashBag. They would not be going to persist anyway. */ - $hashCache = [ 'class' => 'HashBagOStuff', 'reportDupes' => false ]; + $hashCache = [ 'class' => HashBagOStuff::class, 'reportDupes' => false ]; $objectCaches = [ CACHE_DB => $hashCache, CACHE_ACCEL => $hashCache, CACHE_MEMCACHED => $hashCache, 'apc' => $hashCache, 'apcu' => $hashCache, - 'xcache' => $hashCache, 'wincache' => $hashCache, ] + $baseConfig->get( 'ObjectCaches' ); $defaultOverrides->set( 'ObjectCaches', $objectCaches ); $defaultOverrides->set( 'MainCacheType', CACHE_NONE ); - $defaultOverrides->set( 'JobTypeConf', [ 'default' => [ 'class' => 'JobQueueMemory' ] ] ); + $defaultOverrides->set( 'JobTypeConf', [ 'default' => [ 'class' => JobQueueMemory::class ] ] ); // Use a fast hash algorithm to hash passwords. $defaultOverrides->set( 'PasswordDefault', 'A' ); @@ -1080,6 +1080,8 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { } } + SiteStatsInit::doPlaceholderInit(); + User::resetIdByNameCache(); // Make sysop user @@ -1474,44 +1476,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { } } - /** - * @since 1.18 - * - * @param string $func - * @param array $args - * - * @return mixed - * @throws MWException - */ - public function __call( $func, $args ) { - static $compatibility = [ - 'createMock' => 'createMock2', - ]; - - if ( isset( $compatibility[$func] ) ) { - return call_user_func_array( [ $this, $compatibility[$func] ], $args ); - } else { - throw new MWException( "Called non-existent $func method on " . static::class ); - } - } - - /** - * Return a test double for the specified class. - * - * @param string $originalClassName - * @return PHPUnit_Framework_MockObject_MockObject - * @throws Exception - */ - private function createMock2( $originalClassName ) { - return $this->getMockBuilder( $originalClassName ) - ->disableOriginalConstructor() - ->disableOriginalClone() - ->disableArgumentCloning() - // New in phpunit-mock-objects 3.2 (phpunit 5.4.0) - // ->disallowMockingUnknownTypes() - ->getMock(); - } - private static function unprefixTable( &$tableName, $ind, $prefix ) { $tableName = substr( $tableName, strlen( $prefix ) ); } @@ -1596,9 +1560,9 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { * @param string $function */ public function hideDeprecated( $function ) { - MediaWiki\suppressWarnings(); + Wikimedia\suppressWarnings(); wfDeprecated( $function ); - MediaWiki\restoreWarnings(); + Wikimedia\restoreWarnings(); } /** @@ -1892,9 +1856,9 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { # This check may also protect against code injection in # case of broken installations. - MediaWiki\suppressWarnings(); + Wikimedia\suppressWarnings(); $haveDiff3 = $wgDiff3 && file_exists( $wgDiff3 ); - MediaWiki\restoreWarnings(); + Wikimedia\restoreWarnings(); if ( !$haveDiff3 ) { $this->markTestSkipped( "Skip test, since diff3 is not configured" );