Completed
Push — adminicons ( 220b8a...d1a314 )
by Andreas
03:46
created

auth_mock_authplain   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 1
1
<?php
2
3
/**
4
 *  test wrapper to allow access to private/protected functions/properties
5
 *
6
 *  NB: for plugin introspection methods, getPluginType() & getPluginName() to work
7
 *      this class name needs to start "admin_" and end "_usermanager".  Internally
8
 *      these methods are used in setting up the class, e.g. for language strings
9
 */
10
class admin_mock_usermanager extends admin_plugin_usermanager {
11
12
    public $mock_email_notifications = true;
13
    public $mock_email_notifications_sent = 0;
14
15
    public function getImportFailures() {
16
        return $this->_import_failures;
17
    }
18
19
    public function tryExport() {
20
        ob_start();
21
        $this->_export();
22
        return ob_get_clean();
23
    }
24
25
    public function tryImport() {
26
        return $this->_import();
27
    }
28
29
    // no need to send email notifications (mostly)
30
    protected function _notifyUser($user, $password, $status_alert=true) {
31
        if ($this->mock_email_notifications) {
32
            $this->mock_email_notifications_sent++;
33
            return true;
34
        } else {
35
            return parent::_notifyUser($user, $password, $status_alert);
36
        }
37
    }
38
39
    protected function _isUploadedFile($file) {
40
        return file_exists($file);
41
    }
42
}
43
44
class auth_mock_authplain extends auth_plugin_authplain {
45
46
    public function setCanDo($op, $canDo) {
47
        $this->cando[$op] = $canDo;
48
    }
49
50
}
51