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