1<?php
2
3namespace dokuwiki\plugin\bureaucracy\test;
4
5/**
6 * @group plugin_bureaucracy
7 * @group plugins
8 */
9class bureaucracy_field_yesno_test extends BureaucracyTest
10{
11
12    public function dataProvider()
13    {
14        return [
15            [
16                'cb:@@checkbox@@',
17                '"=Yes"',
18                '"!No"',
19                '1',
20                'cb:Yes',
21                [],
22                'default checked substitution',
23            ],
24            [
25                'cb:@@checkbox@@',
26                '"=Yes"',
27                '"!No"',
28                '0',
29                'cb:No',
30                [],
31                'default unchecked substitution',
32            ],
33        ];
34    }
35
36    /**
37     * @dataProvider dataProvider
38     *
39     * @param string $templateSyntax
40     * @param        $YesValue
41     * @param        $NoValue
42     * @param        $isChecked
43     * @param string $expectedWikiText
44     * @param string $expectedValidationErrors
45     * @param string $msg
46     *
47     */
48    public function test_field_yesno(
49        $templateSyntax,
50        $YesValue,
51        $NoValue,
52        $isChecked,
53        $expectedWikiText,
54        $expectedValidationErrors,
55        $msg
56    ) {
57        $actualValidationErrors = [];
58
59        $label = 'checkbox';
60        $actualWikiText = parent::send_form_action_template(
61            "yesno \"$label\" $YesValue $NoValue",
62            $templateSyntax,
63            $actualValidationErrors,
64            $isChecked
65        );
66
67        $this->assertEquals($expectedWikiText, $actualWikiText, $msg);
68        $this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg);
69    }
70}