MediaWiki  1.30.2
TestUserRegistry Class Reference
Collaboration diagram for TestUserRegistry:

Static Public Member Functions

static clear ()
 Clear the registry. More...
 
static getImmutableTestUser ( $groups=[])
 Get a TestUser object that the caller may not modify. More...
 
static getMutableTestUser ( $testName, $groups=[])
 Get a TestUser object that the caller may modify. More...
 
static getNextId ()
 

Static Private Attributes

static int $counter = 0
 Count of users that have been generated. More...
 
static int $randInt
 Random int, included in IDs. More...
 
static TestUser[] $testUsers = []
 (group key => TestUser) More...
 

Detailed Description

Since
1.28

Definition at line 6 of file TestUserRegistry.php.

Member Function Documentation

◆ clear()

static TestUserRegistry::clear ( )
static

Clear the registry.

TestUsers created by this class will not be deleted, but any handles to existing immutable TestUsers will be deleted, ensuring these users are not reused. We don't reset the counter or random string by design.

Since
1.28
Parameters
string[]$groupsGroups the test user should be added to.
Returns
TestUser

Definition at line 107 of file TestUserRegistry.php.

Referenced by MediaWikiTestCase\resetDB().

◆ getImmutableTestUser()

static TestUserRegistry::getImmutableTestUser (   $groups = [])
static

Get a TestUser object that the caller may not modify.

Whenever possible, unit tests should use immutable users, because immutable users can be reused in multiple tests, which helps keep the unit tests fast.

Since
1.28
Parameters
string[]$groupsGroups the test user should be added to.
Returns
TestUser

Definition at line 60 of file TestUserRegistry.php.

References $username, getNextId(), and wfRandomString().

Referenced by MediaWikiTestCase\getTestUser().

◆ getMutableTestUser()

static TestUserRegistry::getMutableTestUser (   $testName,
  $groups = [] 
)
static

Get a TestUser object that the caller may modify.

Since
1.28
Parameters
string$testNameCaller's CLASS. Used to generate the user's username.
string[]$groupsGroups the test user should be added to.
Returns
TestUser

Definition at line 34 of file TestUserRegistry.php.

References getNextId(), and wfRandomString().

Referenced by MediaWikiTestCase\getMutableTestUser().

◆ getNextId()

static TestUserRegistry::getNextId ( )
static

Definition at line 17 of file TestUserRegistry.php.

Referenced by getImmutableTestUser(), and getMutableTestUser().

Member Data Documentation

◆ $counter

int TestUserRegistry::$counter = 0
staticprivate

Count of users that have been generated.

Definition at line 12 of file TestUserRegistry.php.

◆ $randInt

int TestUserRegistry::$randInt
staticprivate

Random int, included in IDs.

Definition at line 15 of file TestUserRegistry.php.

◆ $testUsers

TestUser [] TestUserRegistry::$testUsers = []
staticprivate

(group key => TestUser)

Definition at line 9 of file TestUserRegistry.php.


The documentation for this class was generated from the following file: