Issues (16)

_test/general.test.php (6 issues)

1
<?php
2
/**
3
 * General tests for the pwaoffline plugin
4
 *
5
 * @group plugin_pwaoffline
6
 * @group plugins
7
 */
8
class general_plugin_pwaoffline_test extends DokuWikiTest
0 ignored issues
show
The type DokuWikiTest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
{
10
11
    /**
12
     * Simple test to make sure the plugin.info.txt is in correct format
13
     */
14
    public function test_plugininfo()
15
    {
16
        $file = __DIR__ . '/../plugin.info.txt';
17
        $this->assertFileExists($file);
18
19
        $info = confToHash($file);
0 ignored issues
show
The function confToHash was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        $info = /** @scrutinizer ignore-call */ confToHash($file);
Loading history...
20
21
        $this->assertArrayHasKey('base', $info);
22
        $this->assertArrayHasKey('author', $info);
23
        $this->assertArrayHasKey('email', $info);
24
        $this->assertArrayHasKey('date', $info);
25
        $this->assertArrayHasKey('name', $info);
26
        $this->assertArrayHasKey('desc', $info);
27
        $this->assertArrayHasKey('url', $info);
28
29
        $this->assertEquals('pwaoffline', $info['base']);
30
        $this->assertRegExp('/^https?:\/\//', $info['url']);
31
        $this->assertTrue(mail_isvalid($info['email']));
0 ignored issues
show
The function mail_isvalid was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
        $this->assertTrue(/** @scrutinizer ignore-call */ mail_isvalid($info['email']));
Loading history...
32
        $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']);
33
        $this->assertTrue(false !== strtotime($info['date']));
34
    }
35
36
    /**
37
     * Test to ensure that every conf['...'] entry in conf/default.php has a corresponding meta['...'] entry in
38
     * conf/metadata.php.
39
     */
40
    public function test_plugin_conf()
41
    {
42
        $conf_file = __DIR__ . '/../conf/default.php';
43
        if (file_exists($conf_file)) {
44
            include($conf_file);
45
        }
46
        $meta_file = __DIR__ . '/../conf/metadata.php';
47
        if (file_exists($meta_file)) {
48
            include($meta_file);
49
        }
50
51
        $this->assertEquals(
52
            gettype($conf),
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $conf seems to be never defined.
Loading history...
53
            gettype($meta),
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $meta seems to be never defined.
Loading history...
54
            'Both ' . DOKU_PLUGIN . 'pwaoffline/conf/default.php and ' . DOKU_PLUGIN . 'pwaoffline/conf/metadata.php have to exist and contain the same keys.'
0 ignored issues
show
The constant DOKU_PLUGIN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
55
        );
56
57
        if (gettype($conf) != 'NULL' && gettype($meta) != 'NULL') {
58
            foreach ($conf as $key => $value) {
59
                $this->assertArrayHasKey(
60
                    $key,
61
                    $meta,
62
                    'Key $meta[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'pwaoffline/conf/metadata.php'
63
                );
64
            }
65
66
            foreach ($meta as $key => $value) {
67
                $this->assertArrayHasKey(
68
                    $key,
69
                    $conf,
70
                    'Key $conf[\'' . $key . '\'] missing in ' . DOKU_PLUGIN . 'pwaoffline/conf/default.php'
71
                );
72
            }
73
        }
74
75
    }
76
}
77