// for User::getActorId()
'wgActorTableSchemaMigrationStage' => $stage
] );
- $this->overrideMwServices();
$user = $this->getMutableTestUser()->getUser();
$userIdentity = $this->getMock( UserIdentity::class );
// Note, there are some obscure globals which
// could affect the results which aren't included above.
- $this->overrideMwServices();
$context = RequestContext::getMain();
$resp = $context->getRequest()->response();
$conf = $context->getConfig();
fwrite( $f, 'Message' );
fclose( $f );
- // Reset the service to avoid cached results
- $this->overrideMwServices();
-
$this->assertTrue( wfReadOnly() );
$this->assertTrue( wfReadOnly() ); # Check cached
}
$this->setMwGlobals( [
'wgReadOnly' => 'reason'
] );
- $this->overrideMwServices();
$this->assertSame( 'reason', wfReadOnlyReason() );
}
// Don't try to fetch the files from Commons or anything, please
$this->setMwGlobals( 'wgForeignFileRepos', [] );
- // We need to reset services immediately so that editPage() doesn't use the old RepoGroup
- // and hit the network
- $this->resetServices();
// XXX How do we get file redirects to work?
$this->editPage( 'File:Redirect to bad.jpg', '#REDIRECT [[Bad.jpg]]' );
*/
public function testRawHtmlInMsg() {
$this->setMwGlobals( 'wgRawHtml', true );
- // We have to reset the core hook registration.
- // to register the html hook
- $this->overrideMwServices();
$msg = new RawMessage( '<html><script>alert("xss")</script></html>' );
$txt = '<span class="error"><html> tags cannot be' .
foreach ( $extraOptions as $key => $val ) {
$this->setMwGlobals( "wg$key", $val );
}
- $this->overrideMwServices();
$this->setService( 'RepoGroup', $this->getMockRepoGroup() );
// This returns true instead of an array if there are no errors
$this->hideDeprecated( 'Title::isValidMoveOperation' );
$this->user = $this->userUser;
}
-
- $this->resetServices();
}
public function tearDown() {
} else {
$this->user = $this->altUser;
}
- $this->resetServices();
}
/**
global $wgGroupPermissions;
$old = $wgGroupPermissions;
- $wgGroupPermissions = [];
- $this->resetServices();
+ $this->setMwGlobals( 'wgGroupPermissions', [] );
$this->assertEquals( $check[$action][1],
MediaWikiServices::getInstance()->getPermissionManager()
$this->assertEquals( $check[$action][1],
MediaWikiServices::getInstance()->getPermissionManager()
->getPermissionErrors( $action, $this->user, $this->title, 'secure' ) );
- $wgGroupPermissions = $old;
- $this->resetServices();
+ $this->setMwGlobals( 'wgGroupPermissions', $old );
$this->overrideUserPermissions( $this->user, $action );
$this->assertEquals( $check[$action][2],
}
protected function runGroupPermissions( $perm, $action, $result, $result2 = null ) {
- global $wgGroupPermissions;
-
if ( $result2 === null ) {
$result2 = $result;
}
- $wgGroupPermissions['autoconfirmed']['move'] = false;
- $wgGroupPermissions['user']['move'] = false;
- $this->resetServices();
+ $this->setGroupPermissions( 'autoconfirmed', 'move', false );
+ $this->setGroupPermissions( 'user', 'move', false );
$this->overrideUserPermissions( $this->user, $perm );
$res = MediaWikiServices::getInstance()->getPermissionManager()
->getPermissionErrors( $action, $this->user, $this->title );
$this->assertEquals( $result, $res );
- $wgGroupPermissions['autoconfirmed']['move'] = true;
- $wgGroupPermissions['user']['move'] = false;
- $this->resetServices();
+ $this->setGroupPermissions( 'autoconfirmed', 'move', true );
+ $this->setGroupPermissions( 'user', 'move', false );
$this->overrideUserPermissions( $this->user, $perm );
$res = MediaWikiServices::getInstance()->getPermissionManager()
->getPermissionErrors( $action, $this->user, $this->title );
$this->assertEquals( $result2, $res );
- $wgGroupPermissions['autoconfirmed']['move'] = true;
- $wgGroupPermissions['user']['move'] = true;
- $this->resetServices();
+ $this->setGroupPermissions( 'autoconfirmed', 'move', true );
+ $this->setGroupPermissions( 'user', 'move', true );
$this->overrideUserPermissions( $this->user, $perm );
$res = MediaWikiServices::getInstance()->getPermissionManager()
->getPermissionErrors( $action, $this->user, $this->title );
$this->assertEquals( $result2, $res );
- $wgGroupPermissions['autoconfirmed']['move'] = false;
- $wgGroupPermissions['user']['move'] = true;
- $this->resetServices();
+ $this->setGroupPermissions( 'autoconfirmed', 'move', false );
+ $this->setGroupPermissions( 'user', 'move', true );
$this->overrideUserPermissions( $this->user, $perm );
$res = MediaWikiServices::getInstance()->getPermissionManager()
->getPermissionErrors( $action, $this->user, $this->title );
->getPermissionErrors( 'edit', $this->user, $this->title ) );
$this->setMwGlobals( 'wgEmailConfirmToEdit', false );
- $this->resetServices();
$this->overrideUserPermissions( $this->user, [
'createpage',
'edit',
$rights = array_diff( $rights, [ 'writetest' ] );
} );
- $this->resetServices();
$rights = MediaWikiServices::getInstance()
->getPermissionManager()
->getUserPermissions( $user );
'wgRestrictionLevels' => [ '', 'autoconfirmed', 'sysop' ],
'wgAutopromote' => []
] );
- $this->resetServices();
$user = is_null( $userGroups ) ? null : $this->getTestUser( $userGroups )->getUser();
$this->assertSame( $expected, MediaWikiServices::getInstance()
->getPermissionManager()
$this->originalHandlers = TestingAccessWrapper::newFromClass( Hooks::class )->handlers;
TestingAccessWrapper::newFromClass( Hooks::class )->handlers = [];
-
- $this->overrideMwServices();
}
public function tearDown() {
$user = User::newFromName( 'Test user' );
// Don't allow the rights to everybody so that user rights kick in.
$this->mergeMwGlobalArrayValue( 'wgGroupPermissions', [ '*' => $userRights ] );
- $this->resetServices();
$this->overrideUserPermissions(
$user,
array_keys( array_filter( $userRights ), function ( $value ) {
*/
public function testRevisionSelectFields( $migrationStageSettings, $expected ) {
$this->setMwGlobals( $migrationStageSettings );
- $this->overrideMwServices();
$this->hideDeprecated( 'Revision::selectFields' );
$this->assertArrayEqualsIgnoringIntKeyOrder( $expected, Revision::selectFields() );
*/
public function testRevisionSelectArchiveFields( $migrationStageSettings, $expected ) {
$this->setMwGlobals( $migrationStageSettings );
- $this->overrideMwServices();
$this->hideDeprecated( 'Revision::selectArchiveFields' );
$this->assertArrayEqualsIgnoringIntKeyOrder( $expected, Revision::selectArchiveFields() );
public function testRevisionUserJoinCond() {
$this->hideDeprecated( 'Revision::userJoinCond' );
$this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_OLD );
- $this->overrideMwServices();
$this->assertEquals(
[ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
Revision::userJoinCond()
*/
public function testRevisionGetArchiveQueryInfo( $migrationStageSettings, $expected ) {
$this->setMwGlobals( $migrationStageSettings );
- $this->overrideMwServices();
$queryInfo = Revision::getArchiveQueryInfo();
$this->assertQueryInfoEquals( $expected, $queryInfo );
*/
public function testRevisionGetQueryInfo( $migrationStageSettings, $options, $expected ) {
$this->setMwGlobals( $migrationStageSettings );
- $this->overrideMwServices();
$queryInfo = Revision::getQueryInfo( $options );
$this->assertQueryInfoEquals( $expected, $queryInfo );
*/
public function testRevisionStoreGetQueryInfo( $migrationStageSettings, $options, $expected ) {
$this->setMwGlobals( $migrationStageSettings );
- $this->overrideMwServices();
$store = MediaWikiServices::getInstance()->getRevisionStore();
$expected
) {
$this->setMwGlobals( $migrationStageSettings );
- $this->overrideMwServices();
$store = MediaWikiServices::getInstance()->getRevisionStore();
*/
public function testRevisionStoreGetArchiveQueryInfo( $migrationStageSettings, $expected ) {
$this->setMwGlobals( $migrationStageSettings );
- $this->overrideMwServices();
$store = MediaWikiServices::getInstance()->getRevisionStore();
'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(),
'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
] );
-
- $this->overrideMwServices();
}
protected function addCoreDBData() {
$title = $this->getTestPageTitle();
$rev = $this->getRevisionRecordFromDetailsArray( $revDetails );
- $this->overrideMwServices();
$store = MediaWikiServices::getInstance()->getRevisionStore();
$return = $store->insertRevisionOn( $rev, wfGetDB( DB_MASTER ) );
'user' => true,
];
- $this->overrideMwServices();
$store = MediaWikiServices::getInstance()->getRevisionStore();
// Insert the first revision
* @covers \MediaWiki\Revision\RevisionStore::findSlotContentId
*/
public function testNewNullRevision( Title $title, $revDetails, $comment, $minor = false ) {
- $this->overrideMwServices();
-
$user = TestUserRegistry::getMutableTestUser( __METHOD__ )->getUser();
$page = WikiPage::factory( $title );
*/
public function testNewRevisionFromRow_anonEdit_legacyEncoding() {
$this->setMwGlobals( 'wgLegacyEncoding', 'windows-1252' );
- $this->overrideMwServices();
$page = $this->getTestPage();
$text = __METHOD__ . 'a-ä';
/** @var Revision $rev */
*/
public function testNewRevisionFromArchiveRow_legacyEncoding() {
$this->setMwGlobals( 'wgLegacyEncoding', 'windows-1252' );
- $this->overrideMwServices();
$store = MediaWikiServices::getInstance()->getRevisionStore();
$title = Title::newFromText( __METHOD__ );
$text = __METHOD__ . '-bä';
public function testGetKnownCurrentRevision_userNameChange() {
global $wgActorTableSchemaMigrationStage;
- $this->overrideMwServices();
$cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
$this->setService( 'MainWANObjectCache', $cache );
* @covers \MediaWiki\Revision\RevisionStore::getKnownCurrentRevision
*/
public function testGetKnownCurrentRevision_revDelete() {
- $this->overrideMwServices();
$cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
$this->setService( 'MainWANObjectCache', $cache );
'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
] );
- $this->overrideMwServices();
-
if ( !$this->testPage ) {
/**
* We have to create a new page for each subclass as the page creation may result
* @covers \MediaWiki\Revision\RevisionStore::newMutableRevisionFromArray
*/
public function testConstructFromRowWithBadPageId() {
- $this->overrideMwServices();
Wikimedia\suppressWarnings();
$rev = new Revision( (object)[
'rev_page' => 77777777,
*/
public function testLoadFromTitle() {
$this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_NEW );
- $this->overrideMwServices();
$title = $this->getMockTitle();
$conditions = [
$this->user = $this->userUser;
}
- $this->resetServices();
}
protected function setTitle( $ns, $title = "Main_Page" ) {
global $wgGroupPermissions;
$old = $wgGroupPermissions;
- $wgGroupPermissions = [];
-
- $this->resetServices();
+ $this->setMwGlobals( 'wgGroupPermissions', [] );
$this->assertEquals( $check[$action][1],
$this->title->getUserPermissionsErrors( $action, $this->user, true ) );
$this->assertEquals( $check[$action][1],
$this->title->getUserPermissionsErrors( $action, $this->user, 'secure' ) );
- $wgGroupPermissions = $old;
- $this->resetServices();
+ $this->setMwGlobals( 'wgGroupPermissions', $old );
$this->overrideUserPermissions( $this->user, $action );
$this->assertEquals( $check[$action][2],
}
protected function runGroupPermissions( $action, $result, $result2 = null ) {
- global $wgGroupPermissions;
-
if ( $result2 === null ) {
$result2 = $result;
}
$userPermsOverrides = MediaWikiServices::getInstance()->getPermissionManager()
->getUserPermissions( $this->user );
- $wgGroupPermissions['autoconfirmed']['move'] = false;
- $wgGroupPermissions['user']['move'] = false;
- $this->resetServices();
+ $this->setGroupPermissions( 'autoconfirmed', 'move', false );
+ $this->setGroupPermissions( 'user', 'move', false );
$this->overrideUserPermissions( $this->user, $userPermsOverrides );
$res = $this->title->getUserPermissionsErrors( $action, $this->user );
$this->assertEquals( $result, $res );
- $wgGroupPermissions['autoconfirmed']['move'] = true;
- $wgGroupPermissions['user']['move'] = false;
- $this->resetServices();
+ $this->setGroupPermissions( 'autoconfirmed', 'move', true );
+ $this->setGroupPermissions( 'user', 'move', false );
$this->overrideUserPermissions( $this->user, $userPermsOverrides );
$res = $this->title->getUserPermissionsErrors( $action, $this->user );
$this->assertEquals( $result2, $res );
- $wgGroupPermissions['autoconfirmed']['move'] = true;
- $wgGroupPermissions['user']['move'] = true;
- $this->resetServices();
+ $this->setGroupPermissions( 'autoconfirmed', 'move', true );
+ $this->setGroupPermissions( 'user', 'move', true );
$this->overrideUserPermissions( $this->user, $userPermsOverrides );
$res = $this->title->getUserPermissionsErrors( $action, $this->user );
$this->assertEquals( $result2, $res );
- $wgGroupPermissions['autoconfirmed']['move'] = false;
- $wgGroupPermissions['user']['move'] = true;
- $this->resetServices();
+ $this->setGroupPermissions( 'autoconfirmed', 'move', false );
+ $this->setGroupPermissions( 'user', 'move', true );
$this->overrideUserPermissions( $this->user, $userPermsOverrides );
$res = $this->title->getUserPermissionsErrors( $action, $this->user );
$this->assertEquals( $result2, $res );
'wgEmailAuthentication' => true,
'wgBlockDisablesLogin' => false,
] );
- $this->resetServices();
$this->overrideUserPermissions(
$this->user,
$this->title->getUserPermissionsErrors( 'edit', $this->user ) );
$this->setMwGlobals( 'wgEmailConfirmToEdit', false );
- $this->resetServices();
$this->overrideUserPermissions(
$this->user,
[ 'createpage', 'edit', 'move', 'rollback', 'patrol', 'upload', 'purge' ]
],
],
] );
- $this->resetServices();
$now = time();
$this->user->mBlockedby = $this->user->getName();
]
]
] );
-
- // Reset services since we modified $wgLocalInterwikis
- $this->overrideMwServices();
}
/**
$this->setMwGlobals( 'wgRevokePermissions',
[ 'user' => [ 'applychangetags' => true ] ] );
- $this->resetServices();
-
$this->doBlock( [ 'tags' => 'custom tag' ] );
}
$this->mergeMwGlobalArrayValue( 'wgGroupPermissions',
[ 'sysop' => $newPermissions ] );
- $this->resetServices();
$res = $this->doBlock( [ 'hidename' => '' ] );
$dbw = wfGetDB( DB_MASTER );
$this->setMwGlobals( 'wgRevokePermissions',
[ 'sysop' => [ 'blockemail' => true ] ] );
- $this->resetServices();
-
$this->doBlock( [ 'noemail' => '' ] );
}
ChangeTags::defineTag( 'custom tag' );
$this->setMwGlobals( 'wgRevokePermissions',
[ 'user' => [ 'applychangetags' => true ] ] );
- $this->resetServices();
$this->editPage( $name, 'Some text' );
$this->tablesUsed,
[ 'change_tag', 'change_tag_def', 'logging' ]
);
- $this->resetServices();
}
public function testEdit() {
ChangeTags::defineTag( 'custom tag' );
$this->setMwGlobals( 'wgRevokePermissions',
[ 'user' => [ 'applychangetags' => true ] ] );
- // Supply services with updated globals
- $this->resetServices();
try {
$this->doApiRequestWithToken( [
$this->setMwGlobals( 'wgRevokePermissions',
[ 'user' => [ 'upload' => true ] ] );
- // Supply services with updated globals
- $this->resetServices();
$this->doApiRequestWithToken( [
'action' => 'edit',
'The content you supplied exceeds the article size limit of 1 kilobyte.' );
$this->setMwGlobals( 'wgMaxArticleSize', 1 );
- // Supply services with updated globals
- $this->resetServices();
$text = str_repeat( '!', 1025 );
'The action you have requested is limited to users in the group: ' );
$this->setMwGlobals( 'wgRevokePermissions', [ '*' => [ 'edit' => true ] ] );
- // Supply services with updated globals
- $this->resetServices();
$this->doApiRequestWithToken( [
'action' => 'edit',
$this->setMwGlobals( 'wgRevokePermissions',
[ 'user' => [ 'editcontentmodel' => true ] ] );
- // Supply services with updated globals
- $this->resetServices();
$this->doApiRequestWithToken( [
'action' => 'edit',
public function testSetCacheModeUnrecognized() {
$api = new ApiMain();
$api->setCacheMode( 'unrecognized' );
- $this->resetServices();
$this->assertSame(
'private',
TestingAccessWrapper::newFromObject( $api )->mCacheMode,
$name = ucfirst( __FUNCTION__ );
$this->mergeMwGlobalArrayValue( 'wgNamespacesWithSubpages', [ NS_MAIN => true ] );
- $this->resetServices();
$pages = [ $name, "$name/1", "$name/2", "Talk:$name", "Talk:$name/1", "Talk:$name/3" ];
$ids = [];
$this->setMwGlobals( 'wgExtraInterlanguageLinkPrefixes', [ 'madeuplanguage' ] );
$this->tablesUsed[] = 'interwiki';
- $this->resetServices();
}
/**
if ( $remove ) {
$this->mergeMwGlobalArrayValue( 'wgRemoveGroups', [ 'bureaucrat' => $remove ] );
}
-
- $this->resetServices();
}
/**
ChangeTags::defineTag( 'custom tag' );
$this->setGroupPermissions( 'user', 'applychangetags', false );
- $this->resetServices();
$this->doFailedRightsChange(
'You do not have permission to apply change tags along with your changes.',
global $wgActorTableSchemaMigrationStage;
$reset = new \Wikimedia\ScopedCallback( function ( $v ) {
- global $wgActorTableSchemaMigrationStage;
- $wgActorTableSchemaMigrationStage = $v;
- $this->overrideMwServices();
+ $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', $v );
}, [ $wgActorTableSchemaMigrationStage ] );
// Needs to WRITE_BOTH so READ_OLD tests below work. READ mode here doesn't really matter.
- $wgActorTableSchemaMigrationStage = SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW;
- $this->overrideMwServices();
+ $this->setMwGlobals( 'wgActorTableSchemaMigrationStage',
+ SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW );
$users = [
User::newFromName( '192.168.2.2', false ),
$this->markTestSkippedIfDbType( 'sqlite' );
$this->setMwGlobals( 'wgActorTableSchemaMigrationStage', $stage );
- $this->overrideMwServices();
if ( isset( $params['ucuserids'] ) ) {
$params['ucuserids'] = implode( '|', array_map( 'User::idFromName', $params['ucuserids'] ) );
*/
public function testInterwikiUser( $stage ) {
$this->setMwGlobals( 'wgActorTableSchemaMigrationStage', $stage );
- $this->overrideMwServices();
$params = [
'action' => 'query',
],
'wgProxyWhitelist' => [],
] );
- $this->resetServices();
$status = $this->manager->checkAccountCreatePermissions( new \User );
$this->assertFalse( $status->isOK() );
$this->assertTrue( $status->hasMessage( 'sorbs_create_account_reason' ) );
$this->setMwGlobals( 'wgProxyWhitelist', [ '127.0.0.1' ] );
- $this->resetServices();
$status = $this->manager->checkAccountCreatePermissions( new \User );
$this->assertTrue( $status->isGood() );
}
$this->mergeMwGlobalArrayValue( 'wgObjectCaches',
[ __METHOD__ => [ 'class' => 'HashBagOStuff' ] ] );
$this->setMwGlobals( [ 'wgMainCacheType' => __METHOD__ ] );
- // Supply services with updated globals
- $this->resetServices();
// Set up lots of mocks...
$mocks = [];
private function getBlockManagerConstructorArgs( $overrideConfig ) {
$blockManagerConfig = array_merge( $this->blockManagerConfig, $overrideConfig );
$this->setMwGlobals( $blockManagerConfig );
- $this->overrideMwServices();
return [
new LoggedServiceOptions(
self::$serviceOptionsAccessLog,
// let's choose e.g. German (de)
$this->setUserLang( 'de' );
$this->setContentLang( 'de' );
- $this->resetServices();
}
function addDBDataOnce() {
]
]
] );
- $this->overrideMwServices();
$messageCache = MessageCache::singleton();
$messageCache->enable();
function testHasForeignRepoNegative() {
$this->setMwGlobals( 'wgForeignFileRepos', [] );
- $this->overrideMwServices();
FileBackendGroup::destroySingleton();
$this->assertFalse( RepoGroup::singleton()->hasForeignRepos() );
}
function testForEachForeignRepoNone() {
$this->setMwGlobals( 'wgForeignFileRepos', [] );
- $this->overrideMwServices();
FileBackendGroup::destroySingleton();
$fakeCallback = $this->createMock( RepoGroupTestHelper::class );
$fakeCallback->expects( $this->never() )->method( 'callback' );
'apiThumbCacheExpiry' => 86400,
'directory' => $wgUploadDirectory
] ] );
- $this->overrideMwServices();
FileBackendGroup::destroySingleton();
}
}
}
private function setWgInterwikiCache( $interwikiCache ) {
- $this->overrideMwServices();
MediaWikiServices::getInstance()->resetServiceForTesting( 'InterwikiLookup' );
$this->setMwGlobals( 'wgInterwikiCache', $interwikiCache );
}
/** @covers ObjectCache::newAnything */
public function testNewAnythingNothingNoDb() {
- $this->overrideMwServices();
MediaWiki\MediaWikiServices::disableStorageBackend();
$this->assertInstanceOf(
$this->tablesUsed += $this->getMcrTablesToReset();
- $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_NEW );
- $this->setMwGlobals( 'wgContentHandlerUseDB', $this->getContentHandlerUseDB() );
- $this->setMwGlobals(
- 'wgMultiContentRevisionSchemaMigrationStage',
- $this->getMcrMigrationStage()
- );
- $this->overrideMwServices();
+ $this->setMwGlobals( [
+ 'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
+ 'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(),
+ 'wgMultiContentRevisionSchemaMigrationStage' => $this->getMcrMigrationStage(),
+ ] );
// First create our dummy page
$page = Title::newFromText( 'PageArchiveTest_thePage' );
$this->getMcrMigrationStage()
);
$this->pagesToDelete = [];
-
- $this->overrideMwServices();
}
protected function tearDown() {
* @coversNothing
*/
public function testServiceWiring() {
- $this->overrideMwServices();
-
$ranHook = 0;
$this->setMwGlobals( 'wgHooks', [
'ResourceLoaderRegisterModules' => [
$this->originalHandlers = TestingAccessWrapper::newFromClass( Hooks::class )->handlers;
TestingAccessWrapper::newFromClass( Hooks::class )->handlers = [];
-
- $this->overrideMwServices();
}
public function tearDown() {
public function testRcHidemyselfFilter() {
$this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_NEW );
- $this->overrideMwServices();
$user = $this->getTestUser()->getUser();
$user->getActorId( wfGetDB( DB_MASTER ) );
$this->setMwGlobals(
'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
);
- $this->overrideMwServices();
$user = $this->getTestUser()->getUser();
$user->getActorId( wfGetDB( DB_MASTER ) );
public function testRcHidebyothersFilter() {
$this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_NEW );
- $this->overrideMwServices();
$user = $this->getTestUser()->getUser();
$user->getActorId( wfGetDB( DB_MASTER ) );
$this->setMwGlobals(
'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
);
- $this->overrideMwServices();
$user = $this->getTestUser()->getUser();
$user->getActorId( wfGetDB( DB_MASTER ) );
public function testFilterUserExpLevelAllExperienceLevels() {
$this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_NEW );
- $this->overrideMwServices();
$this->assertConditions(
[
$this->setMwGlobals(
'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
);
- $this->overrideMwServices();
$this->assertConditions(
[
public function testFilterUserExpLevelRegistrered() {
$this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_NEW );
- $this->overrideMwServices();
$this->assertConditions(
[
$this->setMwGlobals(
'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
);
- $this->overrideMwServices();
$this->assertConditions(
[
public function testFilterUserExpLevelUnregistrered() {
$this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_NEW );
- $this->overrideMwServices();
$this->assertConditions(
[
$this->setMwGlobals(
'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
);
- $this->overrideMwServices();
$this->assertConditions(
[
public function testFilterUserExpLevelRegistreredOrLearner() {
$this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_NEW );
- $this->overrideMwServices();
$this->assertConditions(
[
$this->setMwGlobals(
'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
);
- $this->overrideMwServices();
$this->assertConditions(
[
public function testFilterUserExpLevelUnregistreredOrExperienced() {
$this->setMwGlobals( 'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_NEW );
- $this->overrideMwServices();
$conds = $this->buildQuery( [ 'userExpLevel' => 'unregistered;experienced' ] );
$this->setMwGlobals(
'wgActorTableSchemaMigrationStage', SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD
);
- $this->overrideMwServices();
$conds = $this->buildQuery( [ 'userExpLevel' => 'unregistered;experienced' ] );
$count++;
}
] ] );
- $this->overrideMwServices();
$spf = MediaWikiServices::getInstance()->getSpecialPageFactory();
$spf->getNames();
$spf->getNames();
*/
public function testGetPage( $spec, $shouldReuseInstance ) {
$this->mergeMwGlobalArrayValue( 'wgSpecialPages', [ 'testdummy' => $spec ] );
- $this->overrideMwServices();
$page = SpecialPageFactory::getPage( 'testdummy' );
$this->assertInstanceOf( SpecialPage::class, $page );
*/
public function testGetNames() {
$this->mergeMwGlobalArrayValue( 'wgSpecialPages', [ 'testdummy' => SpecialAllPages::class ] );
- $this->overrideMwServices();
$names = SpecialPageFactory::getNames();
$this->assertInternalType( 'array', $names );
*/
public function testResolveAlias() {
$this->setContentLang( 'de' );
- $this->overrideMwServices();
list( $name, $param ) = SpecialPageFactory::resolveAlias( 'Spezialseiten/Foo' );
$this->assertEquals( 'Specialpages', $name );
*/
public function testGetLocalNameFor() {
$this->setContentLang( 'de' );
- $this->overrideMwServices();
$name = SpecialPageFactory::getLocalNameFor( 'Specialpages', 'Foo' );
$this->assertEquals( 'Spezialseiten/Foo', $name );
*/
public function testGetTitleForAlias() {
$this->setContentLang( 'de' );
- $this->overrideMwServices();
$title = SpecialPageFactory::getTitleForAlias( 'Specialpages/Foo' );
$this->assertEquals( 'Spezialseiten/Foo', $title->getText() );
$this->setMwGlobals( 'wgSpecialPages',
array_combine( array_keys( $aliasesList ), array_keys( $aliasesList ) )
);
- $this->overrideMwServices();
$this->setContentLang( $lang );
// Catch the warnings we expect to be raised
}
],
] );
- $this->overrideMwServices();
SpecialPageFactory::getLocalNameFor( 'Specialpages' );
$this->assertTrue( $called, 'Recursive call succeeded' );
}
'wgRestrictionLevels' => [ '', 'autoconfirmed', 'sysop' ],
'wgAutopromote' => []
] );
- $this->resetServices();
$obj = $this->newObj();
$user = is_null( $groups ) ? null : $this->getTestUser( $groups )->getUser();
$this->assertSame( $expected, $obj->getRestrictionLevels( $ns, $user ) );
$this->userTester->addGroup( 'unittesters' );
$this->expiryTime = wfTimestamp( TS_MW, time() + 100500 );
$this->userTester->addGroup( 'testwriters', $this->expiryTime );
-
- $this->resetServices();
}
/**
'wgRevokePermissions' => [],
'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW,
] );
- $this->overrideMwServices();
$this->setUpPermissionGlobals();
RequestContext::getMain()->setRequest( $request );
TestingAccessWrapper::newFromObject( $user )->mRequest = $request;
$request->getSession()->setUser( $user );
- $this->overrideMwServices();
}
/**
$rights = array_diff( $rights, [ 'writetest' ] );
} );
- $this->resetServices();
$rights = $user->getRights();
$this->assertContains( 'test', $rights );
$this->assertContains( 'runtest', $rights );
$this->setMwGlobals( [
'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD,
] );
- $this->overrideMwServices();
$domain = MediaWikiServices::getInstance()->getDBLoadBalancer()->getLocalDomainID();
$this->hideDeprecated( 'User::selectFields' );
// the actual test: change config, reset services.
$this->setMwGlobals( 'wgLanguageCode', 'qqx' );
- $this->resetServices();
// the overridden service instance should still be there
$this->assertSame( $myReadOnlyMode, $services->getService( 'ReadOnlyMode' ) );