[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/lib/plugins/config/_test/ -> LoaderTest.php (source)

   1  <?php
   2  
   3  namespace dokuwiki\plugin\config\test;
   4  
   5  use dokuwiki\plugin\config\core\ConfigParser;
   6  use dokuwiki\plugin\config\core\Loader;
   7  
   8  /**
   9   * @group plugin_config
  10   * @group admin_plugins
  11   * @group plugins
  12   * @group bundled_plugins
  13   */
  14  class LoaderTest extends \DokuWikiTest {
  15  
  16      protected $pluginsEnabled = ['testing'];
  17  
  18      /**
  19       * Ensure loading the config meta data works
  20       */
  21      public function testMetaData() {
  22          $loader = new Loader(new ConfigParser());
  23  
  24          $meta = $loader->loadMeta();
  25          $this->assertTrue(is_array($meta));
  26  
  27          // there should be some defaults
  28          $this->assertArrayHasKey('savedir', $meta);
  29          $this->assertEquals(['savedir', '_caution' => 'danger'], $meta['savedir']);
  30          $this->assertArrayHasKey('proxy____port', $meta);
  31          $this->assertEquals(['numericopt'], $meta['proxy____port']);
  32  
  33          // there should be plugin info
  34          $this->assertArrayHasKey('plugin____testing____plugin_settings_name', $meta);
  35          $this->assertEquals(['fieldset'], $meta['plugin____testing____plugin_settings_name']);
  36          $this->assertArrayHasKey('plugin____testing____schnibble', $meta);
  37          $this->assertEquals(['onoff'], $meta['plugin____testing____schnibble']);
  38      }
  39  
  40      /**
  41       * Ensure loading the defaults work
  42       */
  43      public function testDefaults() {
  44          $loader = new Loader(new ConfigParser());
  45  
  46          $conf = $loader->loadDefaults();
  47          $this->assertTrue(is_array($conf));
  48  
  49          // basic defaults
  50          $this->assertArrayHasKey('title', $conf);
  51          $this->assertEquals('DokuWiki', $conf['title']);
  52  
  53          // plugin defaults
  54          $this->assertArrayHasKey('plugin____testing____schnibble', $conf);
  55          $this->assertEquals(0, $conf['plugin____testing____schnibble']);
  56      }
  57  
  58      /**
  59       * Ensure language loading works
  60       */
  61      public function testLangs() {
  62          $loader = new Loader(new ConfigParser());
  63  
  64          $lang = $loader->loadLangs();
  65          $this->assertTrue(is_array($lang));
  66  
  67          // basics are not included in the returned array!
  68          $this->assertArrayNotHasKey('title', $lang);
  69  
  70          // plugin strings
  71          $this->assertArrayHasKey('plugin____testing____plugin_settings_name', $lang);
  72          $this->assertEquals('Testing', $lang['plugin____testing____plugin_settings_name']);
  73          $this->assertArrayHasKey('plugin____testing____schnibble', $lang);
  74          $this->assertEquals(
  75              'Turns on the schnibble before the frobble is used',
  76              $lang['plugin____testing____schnibble']
  77          );
  78      }
  79  }