Merge "Fix Block::newLoad for IPv6 range blocks"
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiBlockInfoTraitTest.php
1 <?php
2
3 use Wikimedia\TestingAccessWrapper;
4
5 /**
6 * @covers ApiBlockInfoTrait
7 */
8 class ApiBlockInfoTraitTest extends MediaWikiTestCase {
9
10 public function testGetBlockInfo() {
11 $block = new Block();
12 $mock = $this->getMockForTrait( ApiBlockInfoTrait::class );
13 $info = TestingAccessWrapper::newFromObject( $mock )->getBlockInfo( $block );
14 $subset = [
15 'blockid' => null,
16 'blockedby' => '',
17 'blockedbyid' => 0,
18 'blockreason' => '',
19 'blockexpiry' => 'infinite',
20 'blockpartial' => false,
21 ];
22 $this->assertArraySubset( $subset, $info );
23 }
24
25 public function testGetBlockInfoPartial() {
26 $mock = $this->getMockForTrait( ApiBlockInfoTrait::class );
27
28 $block = new Block( [
29 'sitewide' => false,
30 ] );
31 $info = TestingAccessWrapper::newFromObject( $mock )->getBlockInfo( $block );
32 $subset = [
33 'blockid' => null,
34 'blockedby' => '',
35 'blockedbyid' => 0,
36 'blockreason' => '',
37 'blockexpiry' => 'infinite',
38 'blockpartial' => true,
39 ];
40 $this->assertArraySubset( $subset, $info );
41 }
42
43 }