wiki.techinc.nl/tests/phpunit/includes/api/UserWrapper.php
Reedy 1834ee3d8e Fix numerous class/function casing
Change-Id: I23982bfa0548c9ea3bdb432be7982f1563930715
2016-03-18 23:14:49 +00: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();
}
}