aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/plugins/extension/_test/InstallerTest.php
blob: 3228e5d6906bd71b9d8c183ebc94dc22c23590a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

namespace dokuwiki\plugin\extension\test;

use dokuwiki\plugin\extension\Installer;
use DokuWikiTest;

/**
 * Installer tests for the extension plugin
 *
 * @group plugin_extension
 * @group plugins
 */
class InstallerTest extends DokuWikiTest
{

    /**
     * Provide data for testFindExtensions
     */
    public function provideFindExtensionsData()
    {
        return [
            'either1' => ['either1', ['either1' => 'plugin']],
            'eithersub2' => ['eithersub2', ['either2' => 'plugin']],
            'plgfoo5' => ['plgfoo5', ['plugin5' => 'plugin']],
            'plgsub3' => ['plgsub3', ['plugin3' => 'plugin']],
            'plgsub4' => ['plgsub4', ['plugin4' => 'plugin']],
            'plgsub6' => ['plgsub6', ['plugin6' => 'plugin']],
            'plugin1' => ['plugin1', ['plugin1' => 'plugin']],
            'plugin2' => ['plugin2', ['plugin2' => 'plugin']],
            'template1' => ['template1', ['template1' => 'template']],
            'tplfoo5' => ['tplfoo5', ['template5' => 'template']],
            'tplsub3' => ['tplsub3', ['template3' => 'template']],
            'tplsub4' => ['tplsub4', ['template4' => 'template']],
            'tplsub6' => ['tplsub6', ['template6' => 'template']],
            'multi' => ['multi', [
                'multi1' => 'plugin',
                'multi2' => 'plugin',
                'multi3' => 'plugin',
                'multi4' => 'template',
                'multi5' => 'template'
            ]],
        ];
    }

    /**
     * Test finding extensions in given directories
     *
     * @dataProvider provideFindExtensionsData
     * @param string $dir
     * @param array $expected
     */
    public function testFindExtensions($dir, $expected)
    {
        $installer = new Installer();
        $list = $this->callInaccessibleMethod($installer, 'findExtensions', [__DIR__ . '/testdata/' . $dir]);
        $this->assertEquals(count($expected), count($list), 'number of extensions found');

        foreach ($list as $ext) {
            $base = $ext->getBase();
            $this->assertArrayHasKey($base, $expected, 'extension found');
            $this->assertEquals($expected[$base], $ext->getType(), 'extension type');
        }
    }
}