aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/api/ApiQueryUserInfoTest.php
blob: 7dcb75c486018b52723628b2748eb7b61bc569fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php

/**
 * @group medium
 * @covers ApiQueryUserInfo
 */
class ApiQueryUserInfoTest extends ApiTestCase {
	public function testGetBlockInfo() {
		$apiQueryUserInfo = new ApiQueryUserInfo(
			new ApiQuery( new ApiMain( $this->apiContext ), 'userinfo' ),
			'userinfo'
		);

		$block = new Block();
		$info = $apiQueryUserInfo->getBlockInfo( $block );
		$subset = [
			'blockid' => null,
			'blockedby' => '',
			'blockedbyid' => 0,
			'blockreason' => '',
			'blockexpiry' => 'infinite',
			'blockpartial' => false,
		];
		$this->assertArraySubset( $subset, $info );
	}

	public function testGetBlockInfoPartial() {
		$apiQueryUserInfo = new ApiQueryUserInfo(
			new ApiQuery( new ApiMain( $this->apiContext ), 'userinfo' ),
			'userinfo'
		);

		$block = new Block( [
			'sitewide' => false,
		] );
		$info = $apiQueryUserInfo->getBlockInfo( $block );
		$subset = [
			'blockid' => null,
			'blockedby' => '',
			'blockedbyid' => 0,
			'blockreason' => '',
			'blockexpiry' => 'infinite',
			'blockpartial' => true,
		];
		$this->assertArraySubset( $subset, $info );
	}
}