X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FMediaWikiTestCase.php;h=419ff00f85357526caa6ad9077e700c845470534;hb=a98ef5dd96f8c20d182e554848655ac3c8b051f9;hp=9745f5b4276ac670245576ffd44dd2b87c56008e;hpb=1f717d0f74c81c1faaed64647cfa2ccaec93082d;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 9745f5b427..419ff00f85 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -255,6 +255,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { CACHE_ACCEL => $hashCache, CACHE_MEMCACHED => $hashCache, 'apc' => $hashCache, + 'apcu' => $hashCache, 'xcache' => $hashCache, 'wincache' => $hashCache, ] + $baseConfig->get( 'ObjectCaches' ); @@ -438,7 +439,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { * @return string Absolute name of the temporary file */ protected function getNewTempFile() { - $fileName = tempnam( wfTempDir(), 'MW_PHPUnit_' . get_class( $this ) . '_' ); + $fileName = tempnam( wfTempDir(), 'MW_PHPUnit_' . static::class . '_' ); $this->tmpFiles[] = $fileName; return $fileName; @@ -1091,11 +1092,11 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { * Clones all tables in the given database (whatever database that connection has * open), to versions with the test prefix. * - * @param Database $db Database to use + * @param IMaintainableDatabase $db Database to use * @param string $prefix Prefix to use for test tables * @return bool True if tables were cloned, false if only the prefix was changed */ - protected static function setupDatabaseWithTestPrefix( Database $db, $prefix ) { + protected static function setupDatabaseWithTestPrefix( IMaintainableDatabase $db, $prefix ) { $tablesCloned = self::listTables( $db ); $dbClone = new CloneDatabase( $db, $tablesCloned, $prefix ); $dbClone->useTemporaryTables( self::$useTemporaryTables ); @@ -1214,9 +1215,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { list( $proto, $cluster ) = explode( '://', $url, 2 ); // Avoid getMaster() because setupDatabaseWithTestPrefix() // requires Database instead of plain DBConnRef/IDatabase - $lb = $externalStoreDB->getLoadBalancer( $cluster ); - $dbw = $lb->getConnection( DB_MASTER ); - $dbws[] = $dbw; + $dbws[] = $externalStoreDB->getMaster( $cluster ); } } @@ -1305,8 +1304,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { if ( isset( $compatibility[$func] ) ) { return call_user_func_array( [ $this, $compatibility[$func] ], $args ); } else { - throw new MWException( "Called non-existent $func method on " - . get_class( $this ) ); + throw new MWException( "Called non-existent $func method on " . static::class ); } } @@ -1330,11 +1328,11 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { /** * @since 1.18 * - * @param Database $db + * @param IMaintainableDatabase $db * * @return array */ - public static function listTables( Database $db ) { + public static function listTables( IMaintainableDatabase $db ) { $prefix = $db->tablePrefix(); $tables = $db->listTables( $prefix, __METHOD__ ); @@ -1382,6 +1380,8 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { if ( isset( PHPUnitMaintClass::$additionalOptions[$offset] ) ) { return PHPUnitMaintClass::$additionalOptions[$offset]; } + + return null; } /**