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
|
<?php
namespace dokuwiki\plugin\bureaucracy\test;
use Doku_Form;
/**
* @group plugin_bureaucracy
* @group plugins
*/
class bureaucracy_field_radio_test extends BureaucracyTest
{
public function dataProvider()
{
return [
[
'fruits:@@radioLabel@@',
'radio "radioLabel" "Peaches|Apples|Oranges"',
'Peaches',
'fruits:Peaches',
[],
'first option chosen',
],
];
}
/**
* @dataProvider dataProvider
*
* @param string $templateSyntax
* @param string $formSyntax
* @param $postedValue
* @param string $expectedWikiText
* @param string $expectedValidationErrors
* @param string $msg
*
*/
public function test_field_radio_submit(
$templateSyntax,
$formSyntax,
$postedValue,
$expectedWikiText,
$expectedValidationErrors,
$msg
) {
$actualValidationErrors = [];
$label = 'radio';
$actualWikiText = parent::send_form_action_template(
$formSyntax,
$templateSyntax,
$actualValidationErrors,
$postedValue
);
$this->assertEquals($expectedWikiText, $actualWikiText, $msg);
$this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg);
}
public function test_field_date_render()
{
$formSyntax = 'radio "radioLabel" "Peaches|Apples|Oranges"';
$instr = p_get_instructions("<form>\n$formSyntax\n</form>");
$actualHTML = p_render('xhtml', $instr, $info);
$expectedFieldHTML = '<label class="radiolabel "><span>radioLabel <sup>*</sup></span></label><label><input type="radio" name="bureaucracy[0]" value="Peaches" /> <span>Peaches</span></label>
<label><input type="radio" name="bureaucracy[0]" value="Apples" /> <span>Apples</span></label>
<label><input type="radio" name="bureaucracy[0]" value="Oranges" /> <span>Oranges</span></label>';
$expectedHTML = self::FORM_PREFIX_HTML . "\n$expectedFieldHTML\n" . self::FORM_SUFFIX_HTML;
$this->assertEquals(trim($expectedHTML), trim($actualHTML));
}
}
|