1<?php 2/* 3 * Yurii's Gantt Plugin 4 * 5 * Copyright (C) 2020 Yurii K. 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see http://www.gnu.org/licenses 19 */ 20 21/** 22 * General tests for the yuriigantt plugin 23 * 24 * @group plugin_yuriigantt 25 * @group plugins 26 */ 27class general_plugin_yuriigantt_test extends DokuWikiTest 28{ 29 30 /** 31 * Simple test to make sure the plugin.info.txt is in correct format 32 */ 33 public function test_plugininfo() 34 { 35 $file = __DIR__ . '/../plugin.info.txt'; 36 $this->assertFileExists($file); 37 38 $info = confToHash($file); 39 40 $this->assertArrayHasKey('base', $info); 41 $this->assertArrayHasKey('author', $info); 42 $this->assertArrayHasKey('email', $info); 43 $this->assertArrayHasKey('date', $info); 44 $this->assertArrayHasKey('name', $info); 45 $this->assertArrayHasKey('desc', $info); 46 $this->assertArrayHasKey('url', $info); 47 48 $this->assertEquals('yuriigantt', $info['base']); 49 $this->assertRegExp('/^https?:\/\//', $info['url']); 50 $this->assertTrue(mail_isvalid($info['email'])); 51 $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); 52 $this->assertTrue(false !== strtotime($info['date'])); 53 } 54 55 /** 56 * Test to ensure that every conf['...'] entry in conf/default.php has a corresponding meta['...'] entry in 57 * conf/metadata.php. 58 */ 59 public function test_plugin_conf() 60 { 61 $conf_file = __DIR__ . '/../conf/default.php'; 62 if (file_exists($conf_file)) { 63 include($conf_file); 64 } 65 $meta_file = __DIR__ . '/../conf/metadata.php'; 66 if (file_exists($meta_file)) { 67 include($meta_file); 68 } 69 70 $this->assertEquals( 71 gettype($conf), 72 gettype($meta), 73 'Both ' . DOKU_PLUGIN . 'yuriigantt/conf/default.php and ' . DOKU_PLUGIN . 'yuriigantt/conf/metadata.php have to exist and contain the same keys.' 74 ); 75 76 if (gettype($conf) != 'NULL' && gettype($meta) != 'NULL') { 77 foreach ($conf as $key => $value) { 78 $this->assertArrayHasKey( 79 $key, 80 $meta, 81 'Key $meta[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'yuriigantt/conf/metadata.php' 82 ); 83 } 84 85 foreach ($meta as $key => $value) { 86 $this->assertArrayHasKey( 87 $key, 88 $conf, 89 'Key $conf[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'yuriigantt/conf/default.php' 90 ); 91 } 92 } 93 94 } 95} 96