1*69b3e0caSMichael Große<?php 2*69b3e0caSMichael Große 3*69b3e0caSMichael Großedeclare(strict_types=1); 4*69b3e0caSMichael Große 5*69b3e0caSMichael Großenamespace dokuwiki\plugin\structsection\test; 6*69b3e0caSMichael Große 7*69b3e0caSMichael Großeuse DokuWikiTest; 8*69b3e0caSMichael Große 9*69b3e0caSMichael Große/** 10*69b3e0caSMichael Große * General tests for the structsection plugin 11*69b3e0caSMichael Große * 12*69b3e0caSMichael Große * @group plugin_structsection 13*69b3e0caSMichael Große * @group plugins 14*69b3e0caSMichael Große */ 15*69b3e0caSMichael Großefinal class GeneralTest extends DokuWikiTest 16*69b3e0caSMichael Große{ 17*69b3e0caSMichael Große 18*69b3e0caSMichael Große /** 19*69b3e0caSMichael Große * Simple test to make sure the plugin.info.txt is in correct format 20*69b3e0caSMichael Große */ 21*69b3e0caSMichael Große public function testPluginInfo(): void 22*69b3e0caSMichael Große { 23*69b3e0caSMichael Große $file = __DIR__ . '/../plugin.info.txt'; 24*69b3e0caSMichael Große self::assertFileExists($file); 25*69b3e0caSMichael Große 26*69b3e0caSMichael Große $info = confToHash($file); 27*69b3e0caSMichael Große 28*69b3e0caSMichael Große self::assertArrayHasKey('base', $info); 29*69b3e0caSMichael Große self::assertArrayHasKey('author', $info); 30*69b3e0caSMichael Große self::assertArrayHasKey('email', $info); 31*69b3e0caSMichael Große self::assertArrayHasKey('date', $info); 32*69b3e0caSMichael Große self::assertArrayHasKey('name', $info); 33*69b3e0caSMichael Große self::assertArrayHasKey('desc', $info); 34*69b3e0caSMichael Große self::assertArrayHasKey('url', $info); 35*69b3e0caSMichael Große 36*69b3e0caSMichael Große self::assertEquals('structsection', $info[ 'base' ]); 37*69b3e0caSMichael Große self::assertMatchesRegularExpression('/^https?:\/\//', $info[ 'url' ]); 38*69b3e0caSMichael Große self::assertTrue(mail_isvalid($info[ 'email' ])); 39*69b3e0caSMichael Große self::assertMatchesRegularExpression('/^\d\d\d\d-\d\d-\d\d$/', $info[ 'date' ]); 40*69b3e0caSMichael Große self::assertTrue(false !== strtotime($info[ 'date' ])); 41*69b3e0caSMichael Große } 42*69b3e0caSMichael Große 43*69b3e0caSMichael Große /** 44*69b3e0caSMichael Große * Test to ensure that every conf['...'] entry in conf/default.php has a corresponding meta['...'] entry in 45*69b3e0caSMichael Große * conf/metadata.php. 46*69b3e0caSMichael Große */ 47*69b3e0caSMichael Große public function testPluginConf(): void 48*69b3e0caSMichael Große { 49*69b3e0caSMichael Große $conf_file = __DIR__ . '/../conf/default.php'; 50*69b3e0caSMichael Große $meta_file = __DIR__ . '/../conf/metadata.php'; 51*69b3e0caSMichael Große 52*69b3e0caSMichael Große if (!file_exists($conf_file) && !file_exists($meta_file)) { 53*69b3e0caSMichael Große self::markTestSkipped('No config files exist -> skipping test'); 54*69b3e0caSMichael Große } 55*69b3e0caSMichael Große 56*69b3e0caSMichael Große if (file_exists($conf_file)) { 57*69b3e0caSMichael Große include($conf_file); 58*69b3e0caSMichael Große } 59*69b3e0caSMichael Große if (file_exists($meta_file)) { 60*69b3e0caSMichael Große include($meta_file); 61*69b3e0caSMichael Große } 62*69b3e0caSMichael Große 63*69b3e0caSMichael Große self::assertEquals( 64*69b3e0caSMichael Große gettype($conf), 65*69b3e0caSMichael Große gettype($meta), 66*69b3e0caSMichael Große 'Both ' . DOKU_PLUGIN . 'structsection/conf/default.php and ' . DOKU_PLUGIN . 'structsection/conf/metadata.php have to exist and contain the same keys.' 67*69b3e0caSMichael Große ); 68*69b3e0caSMichael Große 69*69b3e0caSMichael Große if ($conf !== null && $meta !== null) { 70*69b3e0caSMichael Große foreach ($conf as $key => $value) { 71*69b3e0caSMichael Große self::assertArrayHasKey( 72*69b3e0caSMichael Große $key, 73*69b3e0caSMichael Große $meta, 74*69b3e0caSMichael Große 'Key $meta[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'structsection/conf/metadata.php' 75*69b3e0caSMichael Große ); 76*69b3e0caSMichael Große } 77*69b3e0caSMichael Große 78*69b3e0caSMichael Große foreach ($meta as $key => $value) { 79*69b3e0caSMichael Große self::assertArrayHasKey( 80*69b3e0caSMichael Große $key, 81*69b3e0caSMichael Große $conf, 82*69b3e0caSMichael Große 'Key $conf[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'structsection/conf/default.php' 83*69b3e0caSMichael Große ); 84*69b3e0caSMichael Große } 85*69b3e0caSMichael Große } 86*69b3e0caSMichael Große } 87*69b3e0caSMichael Große} 88