xref: /dokuwiki/lib/plugins/extension/_test/InstallerTest.php (revision 8fe483c9dd38f0052abe729cc74057c9cdf54ad3)
1*8fe483c9SAndreas Gohr<?php
2*8fe483c9SAndreas Gohr
3*8fe483c9SAndreas Gohrnamespace dokuwiki\plugin\extension\test;
4*8fe483c9SAndreas Gohr
5*8fe483c9SAndreas Gohruse dokuwiki\plugin\extension\Installer;
6*8fe483c9SAndreas Gohruse DokuWikiTest;
7*8fe483c9SAndreas Gohr
8*8fe483c9SAndreas Gohr/**
9*8fe483c9SAndreas Gohr * Installer tests for the extension plugin
10*8fe483c9SAndreas Gohr *
11*8fe483c9SAndreas Gohr * @group plugin_extension
12*8fe483c9SAndreas Gohr * @group plugins
13*8fe483c9SAndreas Gohr */
14*8fe483c9SAndreas Gohrclass InstallerTest extends DokuWikiTest
15*8fe483c9SAndreas Gohr{
16*8fe483c9SAndreas Gohr
17*8fe483c9SAndreas Gohr    /**
18*8fe483c9SAndreas Gohr     * Provide data for testFindExtensions
19*8fe483c9SAndreas Gohr     */
20*8fe483c9SAndreas Gohr    public function provideFindExtensionsData()
21*8fe483c9SAndreas Gohr    {
22*8fe483c9SAndreas Gohr        return [
23*8fe483c9SAndreas Gohr            'either1' => ['either1', ['either1' => 'plugin']],
24*8fe483c9SAndreas Gohr            'eithersub2' => ['eithersub2', ['either2' => 'plugin']],
25*8fe483c9SAndreas Gohr            'plgfoo5' => ['plgfoo5', ['plugin5' => 'plugin']],
26*8fe483c9SAndreas Gohr            'plgsub3' => ['plgsub3', ['plugin3' => 'plugin']],
27*8fe483c9SAndreas Gohr            'plgsub4' => ['plgsub4', ['plugin4' => 'plugin']],
28*8fe483c9SAndreas Gohr            'plgsub6' => ['plgsub6', ['plugin6' => 'plugin']],
29*8fe483c9SAndreas Gohr            'plugin1' => ['plugin1', ['plugin1' => 'plugin']],
30*8fe483c9SAndreas Gohr            'plugin2' => ['plugin2', ['plugin2' => 'plugin']],
31*8fe483c9SAndreas Gohr            'template1' => ['template1', ['template1' => 'template']],
32*8fe483c9SAndreas Gohr            'tplfoo5' => ['tplfoo5', ['template5' => 'template']],
33*8fe483c9SAndreas Gohr            'tplsub3' => ['tplsub3', ['template3' => 'template']],
34*8fe483c9SAndreas Gohr            'tplsub4' => ['tplsub4', ['template4' => 'template']],
35*8fe483c9SAndreas Gohr            'tplsub6' => ['tplsub6', ['template6' => 'template']],
36*8fe483c9SAndreas Gohr            'multi' => ['multi', [
37*8fe483c9SAndreas Gohr                'multi1' => 'plugin',
38*8fe483c9SAndreas Gohr                'multi2' => 'plugin',
39*8fe483c9SAndreas Gohr                'multi3' => 'plugin',
40*8fe483c9SAndreas Gohr                'multi4' => 'template',
41*8fe483c9SAndreas Gohr                'multi5' => 'template'
42*8fe483c9SAndreas Gohr            ]],
43*8fe483c9SAndreas Gohr        ];
44*8fe483c9SAndreas Gohr    }
45*8fe483c9SAndreas Gohr
46*8fe483c9SAndreas Gohr    /**
47*8fe483c9SAndreas Gohr     * Test finding extensions in given directories
48*8fe483c9SAndreas Gohr     *
49*8fe483c9SAndreas Gohr     * @dataProvider provideFindExtensionsData
50*8fe483c9SAndreas Gohr     * @param string $dir
51*8fe483c9SAndreas Gohr     * @param array $expected
52*8fe483c9SAndreas Gohr     */
53*8fe483c9SAndreas Gohr    public function testFindExtensions($dir, $expected)
54*8fe483c9SAndreas Gohr    {
55*8fe483c9SAndreas Gohr        $installer = new Installer();
56*8fe483c9SAndreas Gohr        $list = $this->callInaccessibleMethod($installer, 'findExtensions', [__DIR__ . '/testdata/' . $dir]);
57*8fe483c9SAndreas Gohr        $this->assertEquals(count($expected), count($list), 'number of extensions found');
58*8fe483c9SAndreas Gohr
59*8fe483c9SAndreas Gohr        foreach ($list as $ext) {
60*8fe483c9SAndreas Gohr            $base = $ext->getBase();
61*8fe483c9SAndreas Gohr            $this->assertArrayHasKey($base, $expected, 'extension found');
62*8fe483c9SAndreas Gohr            $this->assertEquals($expected[$base], $ext->getType(), 'extension type');
63*8fe483c9SAndreas Gohr        }
64*8fe483c9SAndreas Gohr    }
65*8fe483c9SAndreas Gohr}
66