diff options
author | Guy Brand <gb@unistra.fr> | 2013-12-08 18:04:50 +0100 |
---|---|---|
committer | Guy Brand <gb@unistra.fr> | 2013-12-08 18:04:50 +0100 |
commit | fb23e32bcb0a62b9d404f89139601341f926c1d9 (patch) | |
tree | 4d30240af3098ab3bf8b6862b412373f988ab2ea /lib/plugins/usermanager/_test/mocks.class.php | |
parent | 2877053aad7cf3e245eaedfe042ccc4ebfcf273b (diff) | |
parent | 8c4759c9d38a21eb352498a8035944ee019e7738 (diff) | |
download | rpg-fb23e32bcb0a62b9d404f89139601341f926c1d9.tar.gz rpg-fb23e32bcb0a62b9d404f89139601341f926c1d9.tar.bz2 |
Merge branch 'master' into stable
Diffstat (limited to 'lib/plugins/usermanager/_test/mocks.class.php')
-rw-r--r-- | lib/plugins/usermanager/_test/mocks.class.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/lib/plugins/usermanager/_test/mocks.class.php b/lib/plugins/usermanager/_test/mocks.class.php new file mode 100644 index 000000000..91c74768c --- /dev/null +++ b/lib/plugins/usermanager/_test/mocks.class.php @@ -0,0 +1,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; + } + +} |