xref: /dokuwiki/lib/plugins/usermanager/_test/mocks.class.php (revision 3a97d936870170491bdd7d03d71143143b10191d)
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
159c9753d6SAndreas Gohr    public $localised;
169c9753d6SAndreas Gohr    public $lang;
179c9753d6SAndreas Gohr
18ed6bf75fSChristopher Smith    public function getImportFailures() {
19*3a97d936SAndreas Gohr        return $this->import_failures;
20ed6bf75fSChristopher Smith    }
21ed6bf75fSChristopher Smith
22ed6bf75fSChristopher Smith    public function tryExport() {
23ed6bf75fSChristopher Smith        ob_start();
24*3a97d936SAndreas Gohr        $this->exportCSV();
25ed6bf75fSChristopher Smith        return ob_get_clean();
26ed6bf75fSChristopher Smith    }
27ed6bf75fSChristopher Smith
28ed6bf75fSChristopher Smith    public function tryImport() {
29*3a97d936SAndreas Gohr        return $this->importCSV();
30ed6bf75fSChristopher Smith    }
31ed6bf75fSChristopher Smith
32ed6bf75fSChristopher Smith    // no need to send email notifications (mostly)
33*3a97d936SAndreas Gohr    protected function notifyUser($user, $password, $status_alert=true) {
34ed6bf75fSChristopher Smith        if ($this->mock_email_notifications) {
35ed6bf75fSChristopher Smith            $this->mock_email_notifications_sent++;
36ed6bf75fSChristopher Smith            return true;
37ed6bf75fSChristopher Smith        } else {
38*3a97d936SAndreas Gohr            return parent::notifyUser($user, $password, $status_alert);
39ed6bf75fSChristopher Smith        }
40ed6bf75fSChristopher Smith    }
41ed6bf75fSChristopher Smith
42*3a97d936SAndreas Gohr    protected function isUploadedFile($file) {
43ed6bf75fSChristopher Smith        return file_exists($file);
44ed6bf75fSChristopher Smith    }
45ed6bf75fSChristopher Smith}
46ed6bf75fSChristopher Smith
47211955beSChristopher Smithclass auth_mock_authplain extends auth_plugin_authplain {
48211955beSChristopher Smith
49211955beSChristopher Smith    public function setCanDo($op, $canDo) {
50211955beSChristopher Smith        $this->cando[$op] = $canDo;
51211955beSChristopher Smith    }
52211955beSChristopher Smith
53211955beSChristopher Smith}
54