3 use MediaWiki\User\UserGroupMembership
;
5 class UserGroupMembershipTest
extends MediaWikiIntegrationTestCase
{
7 protected function setUp(): void
{
10 $this->setGroupPermissions(
22 public static function provideInstantiationValidation() {
24 [ 1, null, null, 1, null, null ],
25 [ 1, 'test', null, 1, 'test', null ],
26 [ 1, 'test', '12345', 1, 'test', '12345' ]
31 * @dataProvider provideInstantiationValidation
32 * @covers \MediaWiki\User\UserGroupMembership
34 public function testInstantiation( $userId, $group, $expiry, $userId_, $group_, $expiry_ ) {
35 $ugm = new UserGroupMembership( $userId, $group, $expiry );
51 * @covers \MediaWiki\User\UserGroupMembership::equals
53 public function testComparison() {
54 $ugm1 = new UserGroupMembership( 1, 'test', '67890' );
55 $ugm2 = new UserGroupMembership( 1, 'test', '67890' );
56 $ugm3 = new UserGroupMembership( 1, 'fail', '67890' );
57 $ugm4 = new UserGroupMembership( 1, 'fail', '12345' );
58 $this->assertTrue( $ugm1->equals( $ugm2 ) );
59 $this->assertTrue( $ugm2->equals( $ugm1 ) );
60 $this->assertFalse( $ugm1->equals( $ugm3 ) );
61 $this->assertFalse( $ugm2->equals( $ugm3 ) );
62 $this->assertFalse( $ugm3->equals( $ugm1 ) );
63 // Ensure expiry is ignored
64 $this->assertTrue( $ugm3->equals( $ugm4 ) );
68 * @covers \MediaWiki\User\UserGroupMembership::isExpired
70 public function testIsExpired() {
71 $ts = wfTimestamp( TS_MW
, time() - 100 );
72 $ugm = new UserGroupMembership( 1, null, $ts );
76 $ts = wfTimestamp( TS_MW
, time() +
100 );
77 $ugm = new UserGroupMembership( 1, null, $ts );
81 $ugm = new UserGroupMembership( 1, null, null );