summaryrefslogtreecommitdiff
path: root/lib/plugins/usermanager/_test/mocks.class.php
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2013-11-28 00:12:38 +0000
committerChristopher Smith <chris@jalakai.co.uk>2013-11-28 00:12:38 +0000
commited6bf75f5a78a346e3c3192b2bab79450e206598 (patch)
treec46f81ef6a8918a94f27bca7c5d1fd77848b060c /lib/plugins/usermanager/_test/mocks.class.php
parentb2c01466e61a7800306d8705eada83563ca90a55 (diff)
downloadrpg-ed6bf75f5a78a346e3c3192b2bab79450e206598.tar.gz
rpg-ed6bf75f5a78a346e3c3192b2bab79450e206598.tar.bz2
Add unit tests for usermanager import & export functions
Diffstat (limited to 'lib/plugins/usermanager/_test/mocks.class.php')
-rw-r--r--lib/plugins/usermanager/_test/mocks.class.php43
1 files changed, 43 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..edf5438b2
--- /dev/null
+++ b/lib/plugins/usermanager/_test/mocks.class.php
@@ -0,0 +1,43 @@
+<?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();
+ }
+
+ // 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);
+ }
+}
+