[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

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

   1  <?php
   2  
   3  namespace dokuwiki\test\conf;
   4  
   5  class CascadeProtectedTest extends \DokuWikiTest
   6  {
   7  
   8      public function setUp(): void
   9      {
  10          global $config_cascade;
  11  
  12          $this->pluginsEnabled = [
  13              'testing'
  14          ];
  15  
  16          $out = "<?php\n/*\n * protected settings, cannot modified in the Config manager\n" .
  17              " * Some test data */\n";
  18          $out .= "\$conf['title'] = 'Protected Title';\n";
  19          $out .= "\$conf['tagline'] = 'Protected Tagline';\n";
  20          $out .= "\$conf['plugin']['testing']['schnibble'] = 1;\n";
  21          $out .= "\$conf['plugin']['testing']['second'] = 'Protected setting';\n";
  22  
  23          file_put_contents(end($config_cascade['main']['protected']), $out);
  24  
  25          parent::setUp();
  26      }
  27  
  28      public function testDefaults()
  29      {
  30          global $conf;
  31  
  32          $this->assertEquals('Protected Title', $conf['title'], 'protected local value, overrides local');
  33          $this->assertEquals('Protected Tagline', $conf['tagline'], 'protected local value, override default');
  34  
  35          $testing = plugin_load('action', 'testing');
  36          $this->assertEquals(1, $testing->getConf('schnibble'), 'protected local value, ');
  37          $this->assertEquals('Protected setting', $testing->getConf('second'), 'protected local value');
  38      }
  39  
  40      public function tearDown(): void
  41      {
  42          global $config_cascade;
  43  
  44          unlink(end($config_cascade['main']['protected']));
  45  
  46          parent::tearDown();
  47      }
  48  }