MediaWiki REL1_27
TestUser Class Reference

Wraps the user object, so we can also retain full access to properties like password if we log in via the API. More...

Collaboration diagram for TestUser:

Public Member Functions

 __construct ( $username, $realname='Real Name', $email='sample @example.com', $groups=[])
 
 getPassword ()
 
 getUser ()
 

Static Public Member Functions

static setPasswordForUser (User $user, $password)
 Set the password on a testing user.
 

Public Attributes

string $password
 
User $user
 
string $username
 

Private Member Functions

 assertNotReal ()
 
 setEmail ( $email)
 
 setPassword ( $password)
 
 setRealName ( $realname)
 

Detailed Description

Wraps the user object, so we can also retain full access to properties like password if we log in via the API.

Definition at line 7 of file TestUser.php.

Constructor & Destructor Documentation

◆ __construct()

TestUser::__construct (   $username,
  $realname = 'Real Name',
  $email = 'sample@example.com',
  $groups = [] 
)

Definition at line 38 of file TestUser.php.

References $username, as, assertNotReal(), setEmail(), setPassword(), setRealName(), and user.

Member Function Documentation

◆ assertNotReal()

TestUser::assertNotReal ( )
private

Definition at line 29 of file TestUser.php.

References $wgDBprefix, and global.

Referenced by __construct().

◆ getPassword()

TestUser::getPassword ( )
Returns
string

Definition at line 155 of file TestUser.php.

References $password.

◆ getUser()

TestUser::getUser ( )
Returns
User

Definition at line 148 of file TestUser.php.

References $user.

◆ setEmail()

TestUser::setEmail (   $email)
private
Parameters
string$email
Returns
bool

Definition at line 102 of file TestUser.php.

References user.

Referenced by __construct().

◆ setPassword()

TestUser::setPassword (   $password)
private
Parameters
string$password

Definition at line 114 of file TestUser.php.

References $password, setPasswordForUser(), and user.

Referenced by __construct().

◆ setPasswordForUser()

static TestUser::setPasswordForUser ( User  $user,
  $password 
)
static

Set the password on a testing user.

This assumes we're still using the generic AuthManager config from PHPUnitMaintClass::finalSetup(), and just sets the password in the database directly.

Parameters
User$user
string$password
Examples
/src/tests/phpunit/MediaWikiTestCase.php.

Definition at line 127 of file TestUser.php.

References $password, $user, DB_MASTER, User\getId(), RequestContext\getMain(), and wfGetDB().

Referenced by UserWrapper\__construct(), MediaWikiTestCase\addCoreDBData(), BlockTest\addDBData(), ApiBlockTest\addDBDataOnce(), GenderCacheTest\addDBDataOnce(), setPassword(), BlockTest\testBlockedUserCanNotCreateAccount(), and BlockTest\testDeprecatedConstructor().

◆ setRealName()

TestUser::setRealName (   $realname)
private
Parameters
string$realname
Returns
bool

Definition at line 89 of file TestUser.php.

References user.

Referenced by __construct().

Member Data Documentation

◆ $password

string TestUser::$password
Deprecated:
Since 1.25. Use TestUser::getPassword()
Access:\n private

Definition at line 20 of file TestUser.php.

Referenced by getPassword(), setPassword(), and setPasswordForUser().

◆ $user

User TestUser::$user
Deprecated:
Since 1.25. Use TestUser::getUser()
Access:\n private

Definition at line 27 of file TestUser.php.

Referenced by getUser(), and setPasswordForUser().

◆ $username

string TestUser::$username
Deprecated:
Since 1.25. Use TestUser::getUser()->getName()
Access:\n private

Definition at line 13 of file TestUser.php.

Referenced by __construct().


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