xref: /dokuwiki/lib/plugins/usermanager/_test/mocks.class.php (revision bb70bdd3bae08eb511f2dbf2e594a53f98efac2b)
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 */
10class 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
44class auth_mock_authplain extends auth_plugin_authplain {
45
46    public function setCanDo($op, $canDo) {
47        $this->cando[$op] = $canDo;
48    }
49
50}
51