general_plugin_description_test   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 24
c 1
b 0
f 0
dl 0
loc 50
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testSyntaxLoading() 0 4 1
A testDescriptionPluginIsLoaded() 0 7 1
A testPluginInfo() 0 20 1
1
<?php
2
3
/**
4
 * General tests for the description plugin.
5
 *
6
 * @group plugin_description
7
 * @group plugins
8
 *
9
 * @author Mark C. Prins <[email protected]>
10
 *
11
 * @phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
12
 * @noinspection AutoloadingIssuesInspection
13
 */
14
class general_plugin_description_test extends DokuWikiTest
15
{
16
17
    protected $pluginsEnabled = array('description');
18
19
    /**
20
     * Simple test to make sure the plugin.info.txt is in correct format
21
     */
22
    final public function testPluginInfo(): void
23
    {
24
        $file = __DIR__ . '/../plugin.info.txt';
25
        $this->assertFileExists($file);
26
27
        $info = confToHash($file);
28
29
        $this->assertArrayHasKey('base', $info);
30
        $this->assertArrayHasKey('author', $info);
31
        $this->assertArrayHasKey('email', $info);
32
        $this->assertArrayHasKey('date', $info);
33
        $this->assertArrayHasKey('name', $info);
34
        $this->assertArrayHasKey('desc', $info);
35
        $this->assertArrayHasKey('url', $info);
36
37
        $this->assertEquals('description', $info['base']);
38
        $this->assertRegExp('/^https?:\/\//', $info['url']);
39
        $this->assertTrue(mail_isvalid($info['email']));
40
        $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']);
41
        $this->assertNotFalse(strtotime($info['date']));
42
    }
43
44
    /**
45
     * test if plugin is loaded.
46
     */
47
    final public function testDescriptionPluginIsLoaded(): void
48
    {
49
        global $plugin_controller;
50
        $this->assertContains(
51
            'description',
52
            $plugin_controller->getList(),
53
            "description plugin is loaded"
54
        );
55
    }
56
57
    /**
58
     * test if plugin is loaded.
59
     */
60
    final public function testSyntaxLoading(): void
61
    {
62
        $index = plugin_load('syntax', 'description');
63
        $this->assertInstanceOf(syntax_plugin_description::class, $index);
64
    }
65
}
66