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