summaryrefslogtreecommitdiff
path: root/platform/www/lib/plugins/bureaucracy/_test/actions_template_noreplace.test.php
blob: dc54878f6a6df3e6ea48d09597f33b5f3c837503 (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php

namespace dokuwiki\plugin\bureaucracy\test;

/**
 * @group plugin_bureaucracy
 * @group plugins
 */
class bureaucracy_actions_template_test extends BureaucracyTest {

    public function dataProvider()
    {
        return [
            [
                'This is <noreplace>test</noreplace>.',
                '',
                '',
                'This is test.',
                [],
                '<noreplace></noreplace> not removed.',
            ],
            [
                '%Y-%m-%d <noreplace>%Y-%m-%d</noreplace>.',
                '',
                '',
                date('Y-m-d') . ' %Y-%m-%d.',
                [],
                'Date replaced inside <noreplace></noreplace>.',
            ],
            [
                '@@test@@ <noreplace>@@test@@</noreplace>.',
                'textbox test',
                'something',
                'something @@test@@.',
                [],
                'Field value replaced inside <noreplace></noreplace>.',
            ],
            [
                '<noreplace>@ID@ @USER@ @MAIL@</noreplace>',
                '',
                '',
                '@ID@ @USER@ @MAIL@',
                [],
                'DokuWiki replacement paterns for templates replaced inside <noreplace></noreplace>.',
            ],
            [
                '<noreplace>@FORMPAGE_ID@ @FORMPAGE_NS@ @FORMPAGE_CURNS@</noreplace>',
                '',
                '',
                '@FORMPAGE_ID@ @FORMPAGE_NS@ @FORMPAGE_CURNS@',
                [],
                '@FORMPAGE_*@ replacement paterns replaced inside <noreplace></noreplace>.',
            ],
            [
                '<noreplace><noinclude>TEST</noinclude></noreplace>',
                '',
                '',
                '<noinclude>TEST</noinclude>',
                [],
                'noinclude tag inside <replaced inside <noreplace></noreplace>.',
            ],
            [
                '<noreplace>@NSBASE@</noreplace>',
                '',
                '',
                '@NSBASE@',
                [],
                '"@NSBASE@" replaced inside <noreplace></noreplace>.',
            ],
            [
                '<noreplace>%%</noreplace>',
                '',
                '',
                '%%',
                [],
                '"%%" replaced inside <noreplace></noreplace>.',
            ]
        ];
    }

    /**
     * @dataProvider dataProvider
     *
     * @param string $templateSyntax
     * @param string $formSyntax
     * @param string $postedValue
     * @param string $expectedWikiText
     * @param string $msg
     *
     */
    public function test_noreplace_tag(
        $templateSyntax,
        $formSyntax,
        $postedValue,
        $expectedWikiText,
        $expectedValidationErrors,
        $msg
    ) {
        $actualValidationErrors = [];

        $actualWikiText = parent::send_form_action_template(
            $formSyntax,
            $templateSyntax,
            $actualValidationErrors,
            $postedValue
        );

        if (empty($expectedValidationErrors)) {
            $this->assertEquals($expectedWikiText, $actualWikiText, $msg);
        }
        $this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg);
    }
}