[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/_test/tests/conf/ -> CascadeExtraDefaultsTest.php (source)

   1  <?php
   2  
   3  namespace dokuwiki\test\conf;
   4  
   5  class CascadeExtraDefaultsTest extends \DokuWikiTest
   6  {
   7  
   8      protected $oldSetting = [];
   9  
  10      public function setUp(): void
  11      {
  12          global $config_cascade;
  13  
  14          $this->pluginsEnabled = [
  15              'testing'
  16          ];
  17  
  18          $out = "<?php\n/*\n * protected settings, cannot modified in the Config manager\n" .
  19              " * Some test data */\n";
  20          $out .= "\$conf['title'] = 'New default Title';\n";
  21          $out .= "\$conf['tagline'] = 'New default Tagline';\n";
  22          $out .= "\$conf['plugin']['testing']['schnibble'] = 1;\n";
  23          $out .= "\$conf['plugin']['testing']['second'] = 'New default setting';\n";
  24  
  25          $file = DOKU_CONF . 'otherdefaults.php';
  26          file_put_contents($file, $out);
  27  
  28          //store original settings
  29          $this->oldSetting = $config_cascade['main']['default'];
  30          //add second file with defaults, which override the defaults of DokuWiki
  31          $config_cascade['main']['default'][] = $file;
  32  
  33          parent::setUp();
  34      }
  35  
  36      public function testNewDefaults()
  37      {
  38          global $conf;
  39  
  40          $this->assertEquals('New default Tagline', $conf['tagline'], 'new default value');
  41          $testing = plugin_load('action', 'testing');
  42          $this->assertEquals(1, $testing->getConf('schnibble'), 'new default value');
  43  
  44  
  45          $this->assertEquals('My Test Wiki', $conf['title'], 'local value still overrides default');
  46          $this->assertEquals('Local setting', $testing->getConf('second'), 'local value still overrides default');
  47      }
  48  
  49      public function tearDown(): void
  50      {
  51          global $config_cascade;
  52  
  53          $config_cascade['main']['default'] = $this->oldSetting;
  54          unlink(DOKU_CONF . 'otherdefaults.php');
  55  
  56          parent::tearDown();
  57      }
  58  }