blob: 99805fa8c6e484891201f5ba48013204f7cbfee6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<?php
namespace dokuwiki\plugin\usermanager\test;
/**
* Simple Auth Plugin for testing
*
* All users are stored in a simple array
* @todo This might be useful for other tests and could replace the remaining mock auth plugins
*/
class AuthPlugin extends \dokuwiki\Extension\AuthPlugin {
public $loggedOff = false;
/** @var array user storage */
public $users = [];
/** @inheritdoc */
public function __construct($cando = []) {
parent::__construct(); // for compatibility
// our own default capabilities
$this->cando['addUser'] = true;
$this->cando['delUser'] = true;
// merge in given capabilities for testing
$this->cando = array_merge($this->cando, $cando);
}
/** @inheritdoc */
public function createUser($user, $pwd, $name, $mail, $grps = null) {
if (isset($this->users[$user])) {
return false;
}
$pass = md5($pwd);
$grps = (array) $grps;
$this->users[$user] = compact('pass', 'name', 'mail', 'grps');
return true;
}
/** @inheritdoc */
public function deleteUsers($users)
{
$deleted = 0;
foreach ($users as $user) {
if (isset($this->users[$user])) {
unset($this->users[$user]);
$deleted++;
}
}
return $deleted;
}
}
|