[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/lib/plugins/usermanager/_test/ -> mocks.class.php (source)

   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   */
  10  class admin_mock_usermanager extends admin_plugin_usermanager {
  11  
  12      public $mock_email_notifications = true;
  13      public $mock_email_notifications_sent = 0;
  14  
  15      public $localised;
  16      public $lang;
  17  
  18      public function getImportFailures() {
  19          return $this->import_failures;
  20      }
  21  
  22      public function tryExport() {
  23          ob_start();
  24          $this->exportCSV();
  25          return ob_get_clean();
  26      }
  27  
  28      public function tryImport() {
  29          return $this->importCSV();
  30      }
  31  
  32      // no need to send email notifications (mostly)
  33      protected function notifyUser($user, $password, $status_alert=true) {
  34          if ($this->mock_email_notifications) {
  35              $this->mock_email_notifications_sent++;
  36              return true;
  37          } else {
  38              return parent::notifyUser($user, $password, $status_alert);
  39          }
  40      }
  41  
  42      protected function isUploadedFile($file) {
  43          return file_exists($file);
  44      }
  45  }
  46  
  47  class auth_mock_authplain extends auth_plugin_authplain {
  48  
  49      public function setCanDo($op, $canDo) {
  50          $this->cando[$op] = $canDo;
  51      }
  52  
  53  }