| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
namespace MediaWiki\Tests\Message; |
| 23 |
|
| 24 |
use MediaWiki\Message\UserGroupMembershipParam; |
| 25 |
use MediaWiki\User\UserIdentity; |
| 26 |
use MediaWiki\User\UserIdentityValue; |
| 27 |
use MediaWikiUnitTestCase; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
class UserGroupMembershipParamTest extends MediaWikiUnitTestCase { |
| 33 |
|
| 34 |
protected string $group; |
| 35 |
protected UserIdentity $member; |
| 36 |
|
| 37 |
protected function setUp(): void { |
| 38 |
parent::setUp(); |
| 39 |
$this->group = 'users'; |
| 40 |
$this->member = new UserIdentityValue( 1, 'MockUser' ); |
| 41 |
} |
| 42 |
|
| 43 |
public function testConstruct() { |
| 44 |
$param = @new UserGroupMembershipParam( $this->group, $this->member ); |
| 45 |
$this->assertSame( $this->group, $param->getGroup() ); |
| 46 |
$this->assertSame( $this->member, $param->getMember() ); |
| 47 |
} |
| 48 |
|
| 49 |
public function testGetGroup() { |
| 50 |
$groupMock = 'users'; |
| 51 |
$userNameMock = 'MockUser'; |
| 52 |
$userIdentityMock = new UserIdentityValue( 1, $userNameMock ); |
| 53 |
$param = @new UserGroupMembershipParam( $groupMock, $userIdentityMock ); |
| 54 |
$this->assertSame( $groupMock, $param->getGroup(), |
| 55 |
'Group name should match the constructor argument.' ); |
| 56 |
} |
| 57 |
|
| 58 |
public function testGetMember() { |
| 59 |
$groupMock = 'users'; |
| 60 |
$userNameMock = 'MockUser'; |
| 61 |
$userIdentityMock = new UserIdentityValue( 1, $userNameMock ); |
| 62 |
$param = @new UserGroupMembershipParam( $groupMock, $userIdentityMock ); |
| 63 |
$this->assertSame( $userIdentityMock, $param->getMember(), |
| 64 |
'User identity object should match the constructor argument.' ); |
| 65 |
} |
| 66 |
|
| 67 |
public function testToString() { |
| 68 |
|
| 69 |
$groupMock = 'sysop'; |
| 70 |
$userIdentityMock = new UserIdentityValue( 2, 'MockAdminUser' ); |
| 71 |
|
| 72 |
|
| 73 |
$param = @new UserGroupMembershipParam( $groupMock, $userIdentityMock ); |
| 74 |
$expectedString = 'sysop:MockAdminUser'; |
| 75 |
|
| 76 |
$this->assertSame( $expectedString, (string)$param, |
| 77 |
'String representation should combine group and user name.' ); |
| 78 |
} |
| 79 |
} |