xref: /dokuwiki/lib/plugins/extension/_test/InstallerTest.php (revision a1ef4d6260401c454faedc5d90cb3887bb07a19c)
18fe483c9SAndreas Gohr<?php
28fe483c9SAndreas Gohr
38fe483c9SAndreas Gohrnamespace dokuwiki\plugin\extension\test;
48fe483c9SAndreas Gohr
58fe483c9SAndreas Gohruse dokuwiki\plugin\extension\Installer;
68fe483c9SAndreas Gohruse DokuWikiTest;
78fe483c9SAndreas Gohr
88fe483c9SAndreas Gohr/**
98fe483c9SAndreas Gohr * Installer tests for the extension plugin
108fe483c9SAndreas Gohr *
118fe483c9SAndreas Gohr * @group plugin_extension
128fe483c9SAndreas Gohr * @group plugins
138fe483c9SAndreas Gohr */
148fe483c9SAndreas Gohrclass InstallerTest extends DokuWikiTest
158fe483c9SAndreas Gohr{
168fe483c9SAndreas Gohr
178fe483c9SAndreas Gohr    /**
188fe483c9SAndreas Gohr     * Provide data for testFindExtensions
198fe483c9SAndreas Gohr     */
208fe483c9SAndreas Gohr    public function provideFindExtensionsData()
218fe483c9SAndreas Gohr    {
228fe483c9SAndreas Gohr        return [
238fe483c9SAndreas Gohr            'either1' => ['either1', ['either1' => 'plugin']],
248fe483c9SAndreas Gohr            'eithersub2' => ['eithersub2', ['either2' => 'plugin']],
258fe483c9SAndreas Gohr            'plgfoo5' => ['plgfoo5', ['plugin5' => 'plugin']],
268fe483c9SAndreas Gohr            'plgsub3' => ['plgsub3', ['plugin3' => 'plugin']],
278fe483c9SAndreas Gohr            'plgsub4' => ['plgsub4', ['plugin4' => 'plugin']],
288fe483c9SAndreas Gohr            'plgsub6' => ['plgsub6', ['plugin6' => 'plugin']],
298fe483c9SAndreas Gohr            'plugin1' => ['plugin1', ['plugin1' => 'plugin']],
308fe483c9SAndreas Gohr            'plugin2' => ['plugin2', ['plugin2' => 'plugin']],
31*a1ef4d62SAndreas Gohr            'plugin3' => ['plugin3', ['foobar' => 'plugin']],
328fe483c9SAndreas Gohr            'template1' => ['template1', ['template1' => 'template']],
338fe483c9SAndreas Gohr            'tplfoo5' => ['tplfoo5', ['template5' => 'template']],
348fe483c9SAndreas Gohr            'tplsub3' => ['tplsub3', ['template3' => 'template']],
358fe483c9SAndreas Gohr            'tplsub4' => ['tplsub4', ['template4' => 'template']],
368fe483c9SAndreas Gohr            'tplsub6' => ['tplsub6', ['template6' => 'template']],
378fe483c9SAndreas Gohr            'multi' => ['multi', [
388fe483c9SAndreas Gohr                'multi1' => 'plugin',
398fe483c9SAndreas Gohr                'multi2' => 'plugin',
408fe483c9SAndreas Gohr                'multi3' => 'plugin',
418fe483c9SAndreas Gohr                'multi4' => 'template',
428fe483c9SAndreas Gohr                'multi5' => 'template'
438fe483c9SAndreas Gohr            ]],
448fe483c9SAndreas Gohr        ];
458fe483c9SAndreas Gohr    }
468fe483c9SAndreas Gohr
478fe483c9SAndreas Gohr    /**
488fe483c9SAndreas Gohr     * Test finding extensions in given directories
498fe483c9SAndreas Gohr     *
508fe483c9SAndreas Gohr     * @dataProvider provideFindExtensionsData
518fe483c9SAndreas Gohr     * @param string $dir
528fe483c9SAndreas Gohr     * @param array $expected
538fe483c9SAndreas Gohr     */
548fe483c9SAndreas Gohr    public function testFindExtensions($dir, $expected)
558fe483c9SAndreas Gohr    {
568fe483c9SAndreas Gohr        $installer = new Installer();
578fe483c9SAndreas Gohr        $list = $this->callInaccessibleMethod($installer, 'findExtensions', [__DIR__ . '/testdata/' . $dir]);
588fe483c9SAndreas Gohr        $this->assertEquals(count($expected), count($list), 'number of extensions found');
598fe483c9SAndreas Gohr
608fe483c9SAndreas Gohr        foreach ($list as $ext) {
618fe483c9SAndreas Gohr            $base = $ext->getBase();
628fe483c9SAndreas Gohr            $this->assertArrayHasKey($base, $expected, 'extension found');
638fe483c9SAndreas Gohr            $this->assertEquals($expected[$base], $ext->getType(), 'extension type');
648fe483c9SAndreas Gohr        }
658fe483c9SAndreas Gohr    }
668fe483c9SAndreas Gohr}
67