The name change happened some time ago, and I think its about time to start using the name name! (Done with a find and replace) My personal motivation for doing this is that I have started trying out vscode as an IDE for mediawiki development, and right now it doesn't appear to handle php aliases very well or at all. Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
use MediaWiki\Block\DatabaseBlock;
|
|
use MediaWiki\Block\SystemBlock;
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
/**
|
|
* @covers ApiBlockInfoTrait
|
|
*/
|
|
class ApiBlockInfoTraitTest extends MediaWikiIntegrationTestCase {
|
|
/**
|
|
* @dataProvider provideGetBlockDetails
|
|
*/
|
|
public function testGetBlockDetails( $block, $expectedInfo ) {
|
|
$mock = $this->getMockForTrait( ApiBlockInfoTrait::class );
|
|
$mock->method( 'getLanguage' )->willReturn( 'en' );
|
|
$info = TestingAccessWrapper::newFromObject( $mock )->getBlockDetails( $block );
|
|
$subset = array_merge( [
|
|
'blockid' => null,
|
|
'blockedby' => '',
|
|
'blockedbyid' => 0,
|
|
'blockreason' => '',
|
|
'blockexpiry' => 'infinite',
|
|
], $expectedInfo );
|
|
$this->assertArraySubmapSame( $subset, $info, "Matching block details" );
|
|
}
|
|
|
|
public static function provideGetBlockDetails() {
|
|
return [
|
|
'Sitewide block' => [
|
|
new DatabaseBlock(),
|
|
[ 'blockpartial' => false ],
|
|
],
|
|
'Partial block' => [
|
|
new DatabaseBlock( [ 'sitewide' => false ] ),
|
|
[ 'blockpartial' => true ],
|
|
],
|
|
'System block' => [
|
|
new SystemBlock( [ 'systemBlock' => 'proxy' ] ),
|
|
[ 'systemblocktype' => 'proxy' ]
|
|
],
|
|
];
|
|
}
|
|
}
|