wiki.techinc.nl/tests/phpunit/includes/api/ApiBlockInfoTraitTest.php
daniel 9f973228d5 Restore ApiQueryUserInfo::getBlockInfo() as a stub.
Fixes unintended breaking change made by I84ed21641c44b2f65ebe.
ApiQueryUserInfo::getBlockInfo() is restoed as a hard deprecated stub.

This renames the method in the new ApiBlockInfoTrait to
getBlockDetails.

Depends-On: I9f40666a31bd4af50762c197c2ce5bf089a5e68c
Change-Id: If47a93878f87d69800e5f305404c22528dac5e94
2019-05-11 07:33:25 +00:00

42 lines
1 KiB
PHP

<?php
use Wikimedia\TestingAccessWrapper;
use MediaWiki\Block\SystemBlock;
/**
* @covers ApiBlockInfoTrait
*/
class ApiBlockInfoTraitTest extends MediaWikiTestCase {
/**
* @dataProvider provideGetBlockDetails
*/
public function testGetBlockDetails( $block, $expectedInfo ) {
$mock = $this->getMockForTrait( ApiBlockInfoTrait::class );
$info = TestingAccessWrapper::newFromObject( $mock )->getBlockDetails( $block );
$subset = array_merge( [
'blockid' => null,
'blockedby' => '',
'blockedbyid' => 0,
'blockreason' => '',
'blockexpiry' => 'infinite',
], $expectedInfo );
$this->assertArraySubset( $subset, $info );
}
public static function provideGetBlockDetails() {
return [
'Sitewide block' => [
new Block(),
[ 'blockpartial' => false ],
],
'Partial block' => [
new Block( [ 'sitewide' => false ] ),
[ 'blockpartial' => true ],
],
'System block' => [
new SystemBlock( [ 'systemBlock' => 'proxy' ] ),
[ 'systemblocktype' => 'proxy' ]
],
];
}
}