1<?php 2 3namespace dokuwiki\plugin\bureaucracyau\test; 4 5use Doku_Form; 6 7/** 8 * @group plugin_bureaucracyau 9 * @group plugins 10 */ 11class bureaucracyau_field_radio_test extends BureaucracyauTest 12{ 13 14 public function dataProvider() 15 { 16 return [ 17 [ 18 'fruits:@@radioLabel@@', 19 'radio "radioLabel" "Peaches|Apples|Oranges"', 20 'Peaches', 21 'fruits:Peaches', 22 [], 23 'first option chosen', 24 ], 25 ]; 26 } 27 28 /** 29 * @dataProvider dataProvider 30 * 31 * @param string $templateSyntax 32 * @param string $formSyntax 33 * @param $postedValue 34 * @param string $expectedWikiText 35 * @param string $expectedValidationErrors 36 * @param string $msg 37 * 38 */ 39 public function test_field_radio_submit( 40 $templateSyntax, 41 $formSyntax, 42 $postedValue, 43 $expectedWikiText, 44 $expectedValidationErrors, 45 $msg 46 ) { 47 $actualValidationErrors = []; 48 49 $label = 'radio'; 50 $actualWikiText = parent::send_form_action_template( 51 $formSyntax, 52 $templateSyntax, 53 $actualValidationErrors, 54 $postedValue 55 ); 56 57 $this->assertEquals($expectedWikiText, $actualWikiText, $msg); 58 $this->assertEquals($expectedValidationErrors, $actualValidationErrors, $msg); 59 } 60 61 public function test_field_date_render() 62 { 63 $formSyntax = 'radio "radioLabel" "Peaches|Apples|Oranges"'; 64 $instr = p_get_instructions("<form>\n$formSyntax\n</form>"); 65 66 $actualHTML = p_render('xhtml', $instr, $info); 67 68 $expectedFieldHTML = '<label class="radiolabel "><span>radioLabel <sup>*</sup></span></label><label><input type="radio" name="bureaucracyau[0]" value="Peaches" /> <span>Peaches</span></label> 69<label><input type="radio" name="bureaucracyau[0]" value="Apples" /> <span>Apples</span></label> 70<label><input type="radio" name="bureaucracyau[0]" value="Oranges" /> <span>Oranges</span></label>'; 71 $expectedHTML = self::FORM_PREFIX_HTML . "\n$expectedFieldHTML\n" . self::FORM_SUFFIX_HTML; 72 $this->assertEquals(trim($expectedHTML), trim($actualHTML)); 73 } 74} 75