The BlockRestrictionStoreFactory is a new service which allows fetching of a wiki-specific BlockRestrictionStore by fetching the correct LoadBalancer via a LBFactory and then injecting it into the BlockRestrictionStore. This is being done as a part of the project of supporting cross-wiki blocking. Currently if a cross-wiki block with restrictions is being created, the block is being stored in the foreign database, but the restrictions are being stored in the local one. Blocks were made wikiaware in I8ae8133f7e232cc75aae6b72fcd7feaeb313cba7. Bug: T291983 Change-Id: Ia342030c31710f40c95acc75d3cc76f1ad79d806
38 lines
1 KiB
PHP
38 lines
1 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\Block;
|
|
|
|
use MediaWiki\Block\BlockRestrictionStore;
|
|
use MediaWiki\Block\BlockRestrictionStoreFactory;
|
|
use MediaWiki\DAO\WikiAwareEntity;
|
|
use MediaWikiUnitTestCase;
|
|
use Wikimedia\Rdbms\LBFactory;
|
|
use Wikimedia\Rdbms\LoadBalancer;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Block\BlockRestrictionStoreFactory
|
|
*/
|
|
class BlockRestrictionStoreFactoryTest extends MediaWikiUnitTestCase {
|
|
|
|
/**
|
|
* @dataProvider provideDomains
|
|
*/
|
|
public function testGetBlockRestrictionStore( $domain ) {
|
|
$lb = $this->createMock( LoadBalancer::class );
|
|
$lbFactory = $this->createMock( LBFactory::class );
|
|
$lbFactory
|
|
->method( 'getMainLB' )
|
|
->with( $domain )
|
|
->willReturn( $lb );
|
|
$factory = new BlockRestrictionStoreFactory( $lbFactory );
|
|
|
|
$restrictionStore = $factory->getBlockRestrictionStore( $domain );
|
|
$this->assertInstanceOf( BlockRestrictionStore::class, $restrictionStore );
|
|
}
|
|
|
|
public function provideDomains() {
|
|
yield 'local wiki' => [ WikiAwareEntity::LOCAL ];
|
|
yield 'foreign wiki' => [ 'meta' ];
|
|
}
|
|
|
|
}
|