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