14515310dSAndreas Gohr<?php 24515310dSAndreas Gohr 34515310dSAndreas Gohrnamespace dokuwiki\plugin\dbquery\test; 44515310dSAndreas Gohr 54515310dSAndreas Gohruse DokuWikiTest; 64515310dSAndreas Gohr 74515310dSAndreas Gohr/** 84515310dSAndreas Gohr * General tests for the dbquery plugin 94515310dSAndreas Gohr * 104515310dSAndreas Gohr * @group plugin_dbquery 114515310dSAndreas Gohr * @group plugins 124515310dSAndreas Gohr */ 134515310dSAndreas Gohrclass GeneralTest extends DokuWikiTest 144515310dSAndreas Gohr{ 154515310dSAndreas Gohr 164515310dSAndreas Gohr /** 174515310dSAndreas Gohr * Simple test to make sure the plugin.info.txt is in correct format 184515310dSAndreas Gohr */ 194515310dSAndreas Gohr public function testPluginInfo(): void 204515310dSAndreas Gohr { 214515310dSAndreas Gohr $file = __DIR__ . '/../plugin.info.txt'; 224515310dSAndreas Gohr $this->assertFileExists($file); 234515310dSAndreas Gohr 244515310dSAndreas Gohr $info = confToHash($file); 254515310dSAndreas Gohr 264515310dSAndreas Gohr $this->assertArrayHasKey('base', $info); 274515310dSAndreas Gohr $this->assertArrayHasKey('author', $info); 284515310dSAndreas Gohr $this->assertArrayHasKey('email', $info); 294515310dSAndreas Gohr $this->assertArrayHasKey('date', $info); 304515310dSAndreas Gohr $this->assertArrayHasKey('name', $info); 314515310dSAndreas Gohr $this->assertArrayHasKey('desc', $info); 324515310dSAndreas Gohr $this->assertArrayHasKey('url', $info); 334515310dSAndreas Gohr 344515310dSAndreas Gohr $this->assertEquals('dbquery', $info['base']); 35*8c959d24SAndreas Gohr $this->assertRegExp('/^https?:\/\//', $info['url']); 364515310dSAndreas Gohr $this->assertTrue(mail_isvalid($info['email'])); 37*8c959d24SAndreas Gohr $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); 384515310dSAndreas Gohr $this->assertTrue(false !== strtotime($info['date'])); 394515310dSAndreas Gohr } 404515310dSAndreas Gohr 414515310dSAndreas Gohr /** 424515310dSAndreas Gohr * Test to ensure that every conf['...'] entry in conf/default.php has a corresponding meta['...'] entry in 434515310dSAndreas Gohr * conf/metadata.php. 444515310dSAndreas Gohr */ 454515310dSAndreas Gohr public function testPluginConf(): void 464515310dSAndreas Gohr { 474515310dSAndreas Gohr $conf_file = __DIR__ . '/../conf/default.php'; 484515310dSAndreas Gohr $meta_file = __DIR__ . '/../conf/metadata.php'; 494515310dSAndreas Gohr 504515310dSAndreas Gohr if (!file_exists($conf_file) && !file_exists($meta_file)) { 514515310dSAndreas Gohr self::markTestSkipped('No config files exist -> skipping test'); 524515310dSAndreas Gohr } 534515310dSAndreas Gohr 544515310dSAndreas Gohr if (file_exists($conf_file)) { 554515310dSAndreas Gohr include($conf_file); 564515310dSAndreas Gohr } 574515310dSAndreas Gohr if (file_exists($meta_file)) { 584515310dSAndreas Gohr include($meta_file); 594515310dSAndreas Gohr } 604515310dSAndreas Gohr 614515310dSAndreas Gohr $this->assertEquals( 624515310dSAndreas Gohr gettype($conf), 634515310dSAndreas Gohr gettype($meta), 644515310dSAndreas Gohr 'Both ' . DOKU_PLUGIN . 'dbquery/conf/default.php and ' . DOKU_PLUGIN . 'dbquery/conf/metadata.php have to exist and contain the same keys.' 654515310dSAndreas Gohr ); 664515310dSAndreas Gohr 674515310dSAndreas Gohr if ($conf !== null && $meta !== null) { 684515310dSAndreas Gohr foreach ($conf as $key => $value) { 694515310dSAndreas Gohr $this->assertArrayHasKey( 704515310dSAndreas Gohr $key, 714515310dSAndreas Gohr $meta, 724515310dSAndreas Gohr 'Key $meta[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'dbquery/conf/metadata.php' 734515310dSAndreas Gohr ); 744515310dSAndreas Gohr } 754515310dSAndreas Gohr 764515310dSAndreas Gohr foreach ($meta as $key => $value) { 774515310dSAndreas Gohr $this->assertArrayHasKey( 784515310dSAndreas Gohr $key, 794515310dSAndreas Gohr $conf, 804515310dSAndreas Gohr 'Key $conf[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'dbquery/conf/default.php' 814515310dSAndreas Gohr ); 824515310dSAndreas Gohr } 834515310dSAndreas Gohr } 844515310dSAndreas Gohr 854515310dSAndreas Gohr } 864515310dSAndreas Gohr} 87