[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace dokuwiki\plugin\config\test\Setting; 4 5 use dokuwiki\plugin\config\core\Setting\Setting; 6 7 abstract class AbstractSettingTest extends \DokuWikiTest { 8 9 /** @var string the class to test */ 10 protected $class; 11 12 /** 13 * Sets up the proper class to test based on the test's class name 14 * @throws \Exception 15 */ 16 public function setUp() : void { 17 parent::setUp(); 18 $class = get_class($this); 19 $class = substr($class, strrpos($class, '\\') + 1, -4); 20 $class = 'dokuwiki\\plugin\\config\\core\\Setting\\' . $class; 21 $this->class = $class; 22 } 23 24 public function testInitialBasics() { 25 /** @var Setting $setting */ 26 $setting = new $this->class('test'); 27 $this->assertEquals('test', $setting->getKey()); 28 $this->assertSame(false, $setting->isProtected()); 29 $this->assertSame(true, $setting->isDefault()); 30 $this->assertSame(false, $setting->hasError()); 31 $this->assertSame(false, $setting->shouldBeSaved()); 32 } 33 34 public function testShouldHaveDefault() { 35 /** @var Setting $setting */ 36 $setting = new $this->class('test'); 37 $this->assertSame(true, $setting->shouldHaveDefault()); 38 } 39 40 public function testPrettyKey() { 41 /** @var Setting $setting */ 42 $setting = new $this->class('test'); 43 $this->assertEquals('test', $setting->getPrettyKey(false)); 44 45 $setting = new $this->class('test____foo'); 46 $this->assertEquals('test»foo', $setting->getPrettyKey(false)); 47 48 $setting = new $this->class('test'); 49 $this->assertEquals( 50 '<a href="https://www.dokuwiki.org/config:test">test</a>', 51 $setting->getPrettyKey(true) 52 ); 53 54 $setting = new $this->class('test____foo'); 55 $this->assertEquals('test»foo', $setting->getPrettyKey(true)); 56 57 $setting = new $this->class('start'); 58 $this->assertEquals( 59 '<a href="https://www.dokuwiki.org/config:startpage">start</a>', 60 $setting->getPrettyKey(true) 61 ); 62 } 63 64 public function testType() { 65 /** @var Setting $setting */ 66 $setting = new $this->class('test'); 67 $this->assertEquals('dokuwiki', $setting->getType()); 68 69 $setting = new $this->class('test_foo'); 70 $this->assertEquals('dokuwiki', $setting->getType()); 71 72 $setting = new $this->class('plugin____test'); 73 $this->assertEquals('plugin', $setting->getType()); 74 75 $setting = new $this->class('tpl____test'); 76 $this->assertEquals('template', $setting->getType()); 77 } 78 79 public function testCaution() { 80 /** @var Setting $setting */ 81 $setting = new $this->class('test'); 82 $this->assertEquals(false, $setting->caution()); 83 84 $setting = new $this->class('test', ['_caution' => 'warning']); 85 $this->assertEquals('warning', $setting->caution()); 86 87 $setting = new $this->class('test', ['_caution' => 'danger']); 88 $this->assertEquals('danger', $setting->caution()); 89 90 $setting = new $this->class('test', ['_caution' => 'security']); 91 $this->assertEquals('security', $setting->caution()); 92 93 $setting = new $this->class('test', ['_caution' => 'flargh']); 94 $this->expectException(\RuntimeException::class); 95 $setting->caution(); 96 } 97 98 99 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body