xref: /dokuwiki/lib/plugins/usermanager/_test/mocks.class.php (revision cf5038dd45e664aedaa343463e9ecdbd34073e8c)
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    /**
30     * @deprecated    remove when dokuwiki requires php 5.3+
31     *                also associated unit test & usermanager methods
32     */
33    public function access_str_getcsv($line){
34        return $this->str_getcsv($line);
35    }
36
37    // no need to send email notifications (mostly)
38    protected function _notifyUser($user, $password, $status_alert=true) {
39        if ($this->mock_email_notifications) {
40            $this->mock_email_notifications_sent++;
41            return true;
42        } else {
43            return parent::_notifyUser($user, $password, $status_alert);
44        }
45    }
46
47    protected function _isUploadedFile($file) {
48        return file_exists($file);
49    }
50}
51
52class auth_mock_authplain extends auth_plugin_authplain {
53
54    public function setCanDo($op, $canDo) {
55        $this->cando[$op] = $canDo;
56    }
57
58}
59