27 if (
$wgDBprefix !== MediaWikiTestCase::DB_PREFIX &&
30 throw new MWException(
"Can't create user on real database" );
35 $email =
'sample@example.com', $groups = []
40 $this->password =
'TestUser';
49 if ( !$this->user->isLoggedIn() ) {
54 "real_name" => $realname
65 $change = $this->
setEmail( $email ) ||
69 $currentGroups = $this->user->getGroups();
70 foreach (
array_diff( $groups, $currentGroups ) as $group ) {
71 $this->user->addGroup( $group );
73 foreach (
array_diff( $currentGroups, $groups ) as $group ) {
74 $this->user->removeGroup( $group );
82 $this->user->mTouched =
'';
83 $this->user->saveSettings();
92 if ( $this->user->getRealName() !== $realname ) {
93 $this->user->setRealName( $realname );
105 if ( $this->user->getEmail() !== $email ) {
106 $this->user->setEmail( $email );
130 if ( !$user->getId() ) {
131 throw new MWException(
"Passed User has not been added to the database yet!" );
135 $row = $dbw->selectRow(
138 [
'user_id' => $user->getId() ],
142 throw new MWException(
"Passed User has an ID but is not in the database?" );
145 $passwordFactory = MediaWikiServices::getInstance()->getPasswordFactory();
146 if ( !$passwordFactory->newFromCiphertext( $row->user_password )->verify(
$password ) ) {
147 $passwordHash = $passwordFactory->newFromPlaintext(
$password );
150 [
'user_password' => $passwordHash->toString() ],
151 [
'user_id' => $user->getId() ],
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$wgDBprefix
Table name prefix.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Wraps the user object, so we can also retain full access to properties like password if we log in via...
static setPasswordForUser(User $user, $password)
Set the password on a testing user.
__construct( $username, $realname='Real Name', $email='sample @example.com', $groups=[])
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static createNew( $name, $params=[])
Add a user to the database, return the user object.