1<?php
2
3namespace dokuwiki\plugin\structacl\test;
4
5use DokuWikiTest;
6
7/**
8 * Config test for the structacl plugin
9 *
10 * @group plugin_structacl
11 * @group plugins
12 */
13class ConfigTest extends DokuWikiTest
14{
15    protected $pluginsEnabled = ['struct', 'structacl'];
16
17    /**
18     * Simple config test
19     */
20    public function testConfig(): void
21    {
22        $confValue = 'schema1.assigned_user
23schema1.reviewer
24schema1.User No. 2
25schema2.reviewer';
26
27        $expected = [
28            'schema1' => [
29                'assigned_user',
30                'reviewer',
31                'User No. 2'
32            ],
33            'schema2' => [
34                'reviewer'
35            ]
36        ];
37
38        /** @var \helper_plugin_structacl $helper */
39        $helper = plugin_load('helper', 'structacl');
40
41        $config = $helper->getConfiguration($confValue);
42
43        $this->assertSame($expected, $config);
44    }
45
46    /**
47     * Test empty config
48     */
49    public function testConfigEmpty(): void
50    {
51        $confValue = '';
52        $expected = [];
53
54        /** @var \helper_plugin_structacl $helper */
55        $helper = plugin_load('helper', 'structacl');
56
57        $config = $helper->getConfiguration($confValue);
58
59        $this->assertSame($expected, $config);
60    }
61
62    /**
63     * Test invalid config
64     */
65    public function testConfigInvalid(): void
66    {
67        $confValue = 'schema:field';
68        $expected = [];
69
70        /** @var \helper_plugin_structacl $helper */
71        $helper = plugin_load('helper', 'structacl');
72
73        $config = $helper->getConfiguration($confValue);
74
75        $this->assertSame($expected, $config);
76    }
77}
78