1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* General tests for the issuelinks plugin |
4
|
|
|
* |
5
|
|
|
* @group plugin_issuelinks |
6
|
|
|
* @group plugins |
7
|
|
|
*/ |
8
|
|
|
class general_plugin_issuelinks_test extends DokuWikiTest { |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Simple test to make sure the plugin.info.txt is in correct format |
12
|
|
|
*/ |
13
|
|
|
public function test_plugininfo() { |
14
|
|
|
$file = __DIR__.'/../plugin.info.txt'; |
15
|
|
|
$this->assertFileExists($file); |
16
|
|
|
|
17
|
|
|
$info = confToHash($file); |
18
|
|
|
|
19
|
|
|
$this->assertArrayHasKey('base', $info); |
20
|
|
|
$this->assertArrayHasKey('author', $info); |
21
|
|
|
$this->assertArrayHasKey('email', $info); |
22
|
|
|
$this->assertArrayHasKey('date', $info); |
23
|
|
|
$this->assertArrayHasKey('name', $info); |
24
|
|
|
$this->assertArrayHasKey('desc', $info); |
25
|
|
|
$this->assertArrayHasKey('url', $info); |
26
|
|
|
|
27
|
|
|
$this->assertEquals('issuelinks', $info['base']); |
28
|
|
|
$this->assertRegExp('/^https?:\/\//', $info['url']); |
29
|
|
|
$this->assertTrue(mail_isvalid($info['email'])); |
30
|
|
|
$this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); |
31
|
|
|
$this->assertTrue(false !== strtotime($info['date'])); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Test to ensure that every conf['...'] entry in conf/default.php has a corresponding meta['...'] entry in |
36
|
|
|
* conf/metadata.php. |
37
|
|
|
*/ |
38
|
|
|
public function test_plugin_conf() { |
39
|
|
|
$conf_file = __DIR__.'/../conf/default.php'; |
40
|
|
|
if (file_exists($conf_file)){ |
41
|
|
|
include($conf_file); |
42
|
|
|
} |
43
|
|
|
$meta_file = __DIR__.'/../conf/metadata.php'; |
44
|
|
|
if (file_exists($meta_file)) { |
45
|
|
|
include($meta_file); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
$this->assertEquals(gettype($conf), gettype($meta),'Both ' . DOKU_PLUGIN . 'issuelinks/conf/default.php and ' . DOKU_PLUGIN . 'issuelinks/conf/metadata.php have to exist and contain the same keys.'); |
|
|
|
|
49
|
|
|
|
50
|
|
|
if (gettype($conf) != 'NULL' && gettype($meta) != 'NULL') { |
51
|
|
|
foreach($conf as $key => $value) { |
52
|
|
|
$this->assertArrayHasKey($key, $meta, 'Key $meta[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'issuelinks/conf/metadata.php'); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
foreach($meta as $key => $value) { |
56
|
|
|
$this->assertArrayHasKey($key, $conf, 'Key $conf[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'issuelinks/conf/default.php'); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|