Introduce a UserGroupManagerFactory and UserGroupManager. The factory utilizes the same pattern as RevisionStore for access to user groups of a foreign wiki. Some user group related methods were ported from User and UserGroupMembership and deprecated, more methods to be moved over in future patches, not to make this one to large. Eventually as all the group-related methods are moved and their usages are replaced, the need for the UserRightsProxy will disappear, thus it also will be deprecated and removed. Currently for backwards compatibility, I've had to create artificial UserIdentityValue objects in some of the deprecated methods to avoid making transitional temporary methods in the UserGroupManager that would take user ID instead of the UserIdentity. All of this will go away once migration to UserGroupManager is completed. Bug: T234921 Change-Id: If29c6a03dfdbb80b2e846243f7e384b334da9f07
48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\User;
|
|
|
|
use FactoryArgTestTrait;
|
|
use MediaWiki\User\UserGroupManager;
|
|
use MediaWiki\User\UserGroupManagerFactory;
|
|
use MediaWikiUnitTestCase;
|
|
use ReflectionParameter;
|
|
use Wikimedia\Rdbms\ILBFactory;
|
|
use Wikimedia\Rdbms\ILoadBalancer;
|
|
|
|
/**
|
|
* @covers \MediaWiki\User\UserGroupManagerFactory
|
|
*/
|
|
class UserGroupManagerFactoryTest extends MediaWikiUnitTestCase {
|
|
use FactoryArgTestTrait;
|
|
|
|
protected static function getFactoryClass() {
|
|
return UserGroupManagerFactory::class;
|
|
}
|
|
|
|
protected static function getInstanceClass() {
|
|
return UserGroupManager::class;
|
|
}
|
|
|
|
protected static function getExtraClassArgCount() {
|
|
return 1;
|
|
}
|
|
|
|
protected function getFactoryMethodName() {
|
|
return 'getUserGroupManager';
|
|
}
|
|
|
|
protected function getIgnoredParamNames() {
|
|
return [ 'hookContainer', 'configuredReadOnlyMode' ];
|
|
}
|
|
|
|
protected function getOverriddenMockValueForParam( ReflectionParameter $param ) {
|
|
if ( $param->getType() && $param->getType()->getName() === ILBFactory::class ) {
|
|
$mock = $this->createNoOpMock( ILBFactory::class, [ 'getMainLB' ] );
|
|
$mock->method( 'getMainLB' )
|
|
->willReturn( $this->createNoOpMock( ILoadBalancer::class ) );
|
|
return [ $mock ];
|
|
}
|
|
return [];
|
|
}
|
|
}
|