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