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