[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/lib/plugins/authplain/_test/ -> userdata.test.php (source)

   1  <?php
   2  
   3  /**
   4   * Class userdata_test
   5   *
   6   * Test group retrieval
   7   *
   8   * @group plugins
   9   */
  10  class userdata_test extends DokuWikiTest
  11  {
  12      /** @var  auth_plugin_authplain */
  13      protected $auth;
  14  
  15      /**
  16       * Load auth with test conf
  17       * @throws Exception
  18       */
  19      public function setUp()
  20      {
  21          parent::setUp();
  22          global $config_cascade;
  23          $config_cascade['plainauth.users']['default'] = __DIR__ . '/conf/auth.users.php';
  24          $this->auth = new auth_plugin_authplain();
  25      }
  26  
  27      /**
  28       * Test that all groups are retrieved in the correct order, without duplicates
  29       */
  30      public function test_retrieve_groups()
  31      {
  32          $expected = ['user', 'first_group', 'second_group', 'third_group', 'fourth_group', 'fifth_group'];
  33          $actual = $this->auth->retrieveGroups();
  34          $this->assertEquals($expected, $actual);
  35      }
  36  
  37      /**
  38       * Test with small and large limits
  39       */
  40      public function test_retrieve_groups_limit()
  41      {
  42          $expected = ['user', 'first_group'];
  43          $actual = $this->auth->retrieveGroups(0, 2);
  44          $this->assertEquals($expected, $actual);
  45  
  46          $expected = ['user', 'first_group', 'second_group', 'third_group', 'fourth_group', 'fifth_group'];
  47          $actual = $this->auth->retrieveGroups(0, 20);
  48          $this->assertEquals($expected, $actual);
  49      }
  50  
  51      /**
  52       * Test with small and large offsets
  53       */
  54      public function test_retrieve_groups_offset()
  55      {
  56          $expected = ['third_group', 'fourth_group', 'fifth_group'];
  57          $actual = $this->auth->retrieveGroups(3,10);
  58          $this->assertEquals($expected, $actual);
  59  
  60          $expected = [];
  61          $actual = $this->auth->retrieveGroups(10,3);
  62          $this->assertEquals($expected, $actual);
  63      }
  64  }