/**
* @since 1.18
*/
-abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
+abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
use MediaWikiCoversValidator;
* 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' );
}
}
+ SiteStatsInit::doPlaceholderInit();
+
User::resetIdByNameCache();
// Make sysop user
$this->ensureMockDatabaseConnection( $db );
foreach ( $tables as $tbl ) {
- $tmp = self::$useTemporaryTables ? ' TEMPORARY ' : '';
$tbl = $db->tableName( $tbl );
- $db->query( "DROP $tmp TABLE IF EXISTS $tbl", __METHOD__ );
+ $db->query( "DROP TABLE IF EXISTS $tbl", __METHOD__ );
if ( $tbl === 'page' ) {
// Forget about the pages since they don't
* @param string $function
*/
public function hideDeprecated( $function ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
wfDeprecated( $function );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
}
/**
* @param string|array $fields The columns to include in the result (and to sort by)
* @param string|array $condition "where" condition(s)
* @param array $expectedRows An array of arrays giving the expected rows.
+ * @param array $options Options for the query
+ * @param array $join_conds Join conditions for the query
*
* @throws MWException If this test cases's needsDB() method doesn't return true.
* Test cases can use "@group Database" to enable database test support,
* or list the tables under testing in $this->tablesUsed, or override the
* needsDB() method.
*/
- protected function assertSelect( $table, $fields, $condition, array $expectedRows ) {
+ protected function assertSelect(
+ $table, $fields, $condition, array $expectedRows, array $options = [], array $join_conds = []
+ ) {
if ( !$this->needsDB() ) {
throw new MWException( 'When testing database state, the test cases\'s needDB()' .
' method should return true. Use @group Database or $this->tablesUsed.' );
$db = wfGetDB( DB_REPLICA );
- $res = $db->select( $table, $fields, $condition, wfGetCaller(), [ 'ORDER BY' => $fields ] );
+ $res = $db->select(
+ $table,
+ $fields,
+ $condition,
+ wfGetCaller(),
+ $options + [ 'ORDER BY' => $fields ],
+ $join_conds
+ );
$this->assertNotEmpty( $res, "query failed: " . $db->lastError() );
$i = 0;
# 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" );