summaryrefslogtreecommitdiff
path: root/lib/plugins/usermanager/_test/mocks.class.php
blob: 91c74768c1ff6af03d9377859eb01fd145351528 (plain)
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
55
56
57
58
<?php

/**
 *  test wrapper to allow access to private/protected functions/properties
 *
 *  NB: for plugin introspection methods, getPluginType() & getPluginName() to work
 *      this class name needs to start "admin_" and end "_usermanager".  Internally
 *      these methods are used in setting up the class, e.g. for language strings
 */
class admin_mock_usermanager extends admin_plugin_usermanager {

    public $mock_email_notifications = true;
    public $mock_email_notifications_sent = 0;

    public function getImportFailures() {
        return $this->_import_failures;
    }

    public function tryExport() {
        ob_start();
        $this->_export();
        return ob_get_clean();
    }

    public function tryImport() {
        return $this->_import();
    }

    /**
     * @deprecated    remove when dokuwiki requires php 5.3+
     *                also associated unit test & usermanager methods
     */
    public function access_str_getcsv($line){
        return $this->str_getcsv($line);
    }

    // no need to send email notifications (mostly)
    protected function _notifyUser($user, $password, $status_alert=true) {
        if ($this->mock_email_notifications) {
            $this->mock_email_notifications_sent++;
            return true;
        } else {
            return parent::_notifyUser($user, $password, $status_alert);
        }
    }

    protected function _isUploadedFile($file) {
        return file_exists($file);
    }
}

class auth_mock_authplain extends auth_plugin_authplain {

    public function setCanDo($op, $canDo) {
        $this->cando[$op] = $canDo;
    }

}