wiki.techinc.nl/tests/phpunit/includes/api/UserWrapper.php
addshore dc18b813e8 Cleanup Api phpunit Tests
- Splits multiple classes into individual files
- Adds @covers tags
- Fixes scope

Change-Id: I7d2816d3574fa53a2aaa8e2a84b7a7ecdd245252
2013-10-24 19:17:01 +01:00

25 lines
No EOL
580 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, array(
"email" => "test@example.com",
"real_name" => "Test User" ) );
}
$this->user->setPassword( $this->password );
if ( $group !== '' ) {
$this->user->addGroup( $group );
}
$this->user->saveSettings();
}
}