1<?php 2 3require_once (__DIR__.'/../webcomponent.php'); 4 5/** 6 * Test the component plugin 7 * 8 * @group plugin_webcomponent 9 * @group plugins 10 */ 11class dokuwiki_plugin_webcomponent_plugin_test extends DokuWikiTest 12{ 13 14 15 protected $pluginsEnabled = array(webcomponent::PLUGIN_NAME); 16 17 /** 18 * Control the plugin.info.txt 19 */ 20 public function test_pluginInfoTxt() 21 { 22 $file = __DIR__ . '/../plugin.info.txt'; 23 $this->assertFileExists($file); 24 25 $info = confToHash($file); 26 27 $this->assertArrayHasKey('base', $info); 28 $this->assertEquals(webcomponent::PLUGIN_NAME, $info['base']); 29 30 $this->assertArrayHasKey('author', $info); 31 $this->assertArrayHasKey('name', $info); 32 $this->assertArrayHasKey('desc', $info); 33 34 $this->assertArrayHasKey('date', $info); 35 $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); 36 $this->assertTrue(false !== strtotime($info['date'])); 37 38 39 $this->assertArrayHasKey('url', $info); 40 $this->assertRegExp('/^https?:\/\//', $info['url']); 41 42 $this->assertArrayHasKey('email', $info); 43 $this->assertTrue(mail_isvalid($info['email'])); 44 45 46 } 47 48 /** 49 * test if the plugin is loaded. 50 */ 51 public function test_plugin_isLoaded() 52 { 53 global $plugin_controller; 54 $this->assertTrue( 55 in_array( 56 webcomponent::PLUGIN_NAME, 57 $plugin_controller->getList()), 58 webcomponent::PLUGIN_NAME . " plugin is loaded" 59 ); 60 } 61 62 /** 63 * Test to ensure that every conf['...'] entry in conf/default.php has a corresponding meta['...'] entry in 64 * conf/metadata.php. 65 */ 66 public function test_plugin_conf() 67 { 68 $conf = array(); 69 $conf_file = __DIR__ . '/../conf/default.php'; 70 if (file_exists($conf_file)) { 71 include($conf_file); 72 } 73 74 $meta = array(); 75 $meta_file = __DIR__ . '/../conf/metadata.php'; 76 if (file_exists($meta_file)) { 77 include($meta_file); 78 } 79 80 81 $this->assertEquals( 82 gettype($conf), 83 gettype($meta), 84 'Both ' . DOKU_PLUGIN . 'syntax/conf/default.php and ' . DOKU_PLUGIN . 'syntax/conf/metadata.php have to exist and contain the same keys.' 85 ); 86 87 if (gettype($conf) != 'NULL' && gettype($meta) != 'NULL') { 88 foreach ($conf as $key => $value) { 89 $this->assertArrayHasKey( 90 $key, 91 $meta, 92 'Key $meta[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'syntax/conf/metadata.php' 93 ); 94 } 95 96 foreach ($meta as $key => $value) { 97 $this->assertArrayHasKey( 98 $key, 99 $conf, 100 'Key $conf[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'syntax/conf/default.php' 101 ); 102 } 103 } 104 105 } 106 107 108} 109