1<?php 2 3/** 4 * General tests for the advanced plugin 5 * 6 * @group tpl_bootstrap3 7 * @group plugins 8 */ 9class general_tpl_bootstrap3_test extends DokuWikiTest 10{ 11 12 /** 13 * Simple test to make sure the template.info.txt is in correct format 14 */ 15 public function test_templateinfo() 16 { 17 $file = __DIR__ . '/../template.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('bootstrap3', $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_tpl_conf() 42 { 43 $conf_file = __DIR__ . '/../conf/default.php'; 44 45 if (file_exists($conf_file)) { 46 include $conf_file; 47 } 48 49 $meta_file = __DIR__ . '/../conf/metadata.php'; 50 51 if (file_exists($meta_file)) { 52 include $meta_file; 53 } 54 55 $this->assertEquals( 56 gettype($conf), 57 gettype($meta), 58 'Both conf/default.php and conf/metadata.php have to exist and contain the same keys.' 59 ); 60 61 if (gettype($conf) != 'NULL' && gettype($meta) != 'NULL') { 62 foreach ($conf as $key => $value) { 63 $this->assertArrayHasKey( 64 $key, 65 $meta, 66 'Key $meta[\'' . $key . '\'] missing in conf/metadata.php' 67 ); 68 } 69 70 foreach ($meta as $key => $value) { 71 $this->assertArrayHasKey( 72 $key, 73 $conf, 74 'Key $conf[\'' . $key . '\'] missing in conf/default.php' 75 ); 76 } 77 } 78 } 79} 80