xref: /plugin/description/_test/general.test.php (revision e689d2932c90c4a915785840f66fe487918d7d88)
1<?php
2/*
3 * @phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
4 * @noinspection AutoloadingIssuesInspection
5 */
6
7/**
8 * General tests for the description plugin
9 *
10 * @group plugin_description
11 * @group plugins
12 *
13 * @author Mark C. Prins <mprins@users.sf.net>
14 */
15class general_plugin_description_test extends DokuWikiTest
16{
17
18    protected $pluginsEnabled = array('description');
19
20    /**
21     * Simple test to make sure the plugin.info.txt is in correct format
22     */
23    public function test_plugininfo(): void
24    {
25        $file = __DIR__ . '/../plugin.info.txt';
26        $this->assertFileExists($file);
27
28        $info = confToHash($file);
29
30        $this->assertArrayHasKey('base', $info);
31        $this->assertArrayHasKey('author', $info);
32        $this->assertArrayHasKey('email', $info);
33        $this->assertArrayHasKey('date', $info);
34        $this->assertArrayHasKey('name', $info);
35        $this->assertArrayHasKey('desc', $info);
36        $this->assertArrayHasKey('url', $info);
37
38        $this->assertEquals('description', $info['base']);
39        $this->assertRegExp('/^https?:\/\//', $info['url']);
40        $this->assertTrue(mail_isvalid($info['email']));
41        $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']);
42        $this->assertTrue(false !== strtotime($info['date']));
43    }
44
45    /**
46     * test if plugin is loaded.
47     */
48    public function test_plugin_description_isloaded()
49    {
50        global $plugin_controller;
51        $this->assertContains(
52            'description', $plugin_controller->getList(), "description plugin is loaded"
53        );
54    }
55}
56