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