wiki.techinc.nl/tests/phpunit/includes/api/UserWrapper.php
Kunal Mehta 6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00

25 lines
593 B
PHP

<?php
class UserWrapper {
public $userName;
public $password;
public $user;
public function __construct( $userName, $password, $group = '' ) {
$this->userName = $userName;
$this->password = $password;
$this->user = User::newFromName( $this->userName );
if ( !$this->user->getID() ) {
$this->user = User::createNew( $this->userName, [
"email" => "test@example.com",
"real_name" => "Test User" ] );
}
TestUser::setPasswordForUser( $this->user, $this->password );
if ( $group !== '' ) {
$this->user->addGroup( $group );
}
$this->user->saveSettings();
}
}