1<?php 2 3/** 4 * General tests for the navi plugin 5 * 6 * @group plugin_navi 7 * @group plugins 8 */ 9class general_plugin_navi_test extends DokuWikiTest 10{ 11 12 /** 13 * Simple test to make sure the plugin.info.txt is in correct format 14 */ 15 public function test_plugininfo() 16 { 17 $file = __DIR__ . '/../plugin.info.txt'; 18 $this->assertFileExists($file); 19 20 $info = confToHash($file); 21 22 $this->assertArrayHasKey('base', $info); 23 $this->assertArrayHasKey('author', $info); 24 $this->assertArrayHasKey('email', $info); 25 $this->assertArrayHasKey('date', $info); 26 $this->assertArrayHasKey('name', $info); 27 $this->assertArrayHasKey('desc', $info); 28 $this->assertArrayHasKey('url', $info); 29 30 $this->assertEquals('navi', $info['base']); 31 $this->assertRegExp('/^https?:\/\//', $info['url']); 32 $this->assertTrue(mail_isvalid($info['email'])); 33 $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); 34 $this->assertTrue(false !== strtotime($info['date'])); 35 } 36 37 /** 38 * Test to ensure that every conf['...'] entry in conf/default.php has a corresponding meta['...'] entry in 39 * conf/metadata.php. 40 */ 41 public function test_plugin_conf() 42 { 43 $conf_file = __DIR__ . '/../conf/default.php'; 44 if (file_exists($conf_file)) { 45 include($conf_file); 46 } 47 $meta_file = __DIR__ . '/../conf/metadata.php'; 48 if (file_exists($meta_file)) { 49 include($meta_file); 50 } 51 52 $this->assertEquals(gettype($conf), gettype($meta), 53 'Both ' . DOKU_PLUGIN . 'navi/conf/default.php and ' . DOKU_PLUGIN . 'navi/conf/metadata.php have to exist and contain the same keys.'); 54 55 if (gettype($conf) != 'NULL' && gettype($meta) != 'NULL') { 56 foreach ($conf as $key => $value) { 57 $this->assertArrayHasKey($key, $meta, 58 'Key $meta[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'navi/conf/metadata.php'); 59 } 60 61 foreach ($meta as $key => $value) { 62 $this->assertArrayHasKey($key, $conf, 63 'Key $conf[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'navi/conf/default.php'); 64 } 65 } 66 67 } 68 69 /*Test that the levels have the right classes 70 public function render_test() { 71 $data = array( 72 0 => '/home/michael/public_html/dokuwiki/data/pages/plugins/navi.txt', 73 1 => array( 74 'lvl1' => array( 75 'parents' => array(), 76 'page' => 'lvl1:start', 77 'title' => '', 78 'lvl' => 1, 79 ), 80 'lvl2' => array( 81 'parents' => Array( 82 0 => 'lvl1', 83 ), 84 'page' => 'lvl2:start', 85 'title' => '', 86 'lvl' => 2, 87 ), 88 'lvl3' => array( 89 'parents' => Array( 90 0 => 'lvl1', 91 1 => 'lvl2', 92 ), 93 'page' => 'lvl3:start', 94 'title' => '', 95 'lvl' => 3, 96 ), 97 'lvl4' => array( 98 'parents' => Array( 99 0 => 'lvl1', 100 1 => 'lvl2', 101 2 => 'lvl3', 102 ), 103 'page' => 'lvl4:start', 104 'title' => '', 105 'lvl' => 4, 106 ), 107 108 ), 109 2 => '', 110 ); 111 render('xhtml',$data); 112 }*/ 113} 114