Translation update done using Pootle.
[phpmyadmin/ammaryasirr.git] / test / libraries / common / PMA_display_html_radio_test.php
blobc5f2d4b89836afdd7936e5ad6c3a51fe201c9d00
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for PMA_display_html_radio from common.lib.php
6 * @package phpMyAdmin-test
7 * @version $Id: PMA_display_html_radio_test.php
8 * @group common.lib-tests
9 */
12 * Include to test.
14 require_once 'libraries/common.lib.php';
16 class PMA_display_html_radio_test extends PHPUnit_Extensions_OutputTestCase
18 function testDisplayHtmlRadioEmpty()
20 $name = "test_display_radio";
21 $choices = array();
23 $this->expectOutputString("");
24 PMA_display_html_radio($name,$choices);
27 function testDisplayHtmlRadio()
29 $name = "test_display_radio";
30 $choices = array('value_1'=>'choice_1', 'value_2'=>'choice_2');
32 $out = "";
33 foreach ($choices as $choice_value => $choice_label) {
34 $html_field_id = $name . '_' . $choice_value;
35 $out .= '<input type="radio" name="' . $name . '" id="' . $html_field_id . '" value="' . htmlspecialchars($choice_value) . '"';
36 $out .= ' />' . "\n";
37 $out .= '<label for="' . $html_field_id . '">' . $choice_label . '</label>';
38 $out .= '<br />';
39 $out .= "\n";
42 $this->expectOutputString($out);
43 PMA_display_html_radio($name,$choices);
46 function testDisplayHtmlRadioWithChecked()
48 $name = "test_display_radio";
49 $choices = array('value_1'=>'choice_1', 'value_2'=>'choice_2');
50 $checked_choice = "value_2";
52 $out = "";
53 foreach ($choices as $choice_value => $choice_label) {
54 $html_field_id = $name . '_' . $choice_value;
55 $out .= '<input type="radio" name="' . $name . '" id="' . $html_field_id . '" value="' . htmlspecialchars($choice_value) . '"';
56 if ($choice_value == $checked_choice) {
57 $out .= ' checked="checked"';
59 $out .= ' />' . "\n";
60 $out .= '<label for="' . $html_field_id . '">' . $choice_label . '</label>';
61 $out .= '<br />';
62 $out .= "\n";
65 $this->expectOutputString($out);
66 PMA_display_html_radio($name,$choices,$checked_choice);
69 function testDisplayHtmlRadioWithCheckedWithClass()
71 $name = "test_display_radio";
72 $choices = array('value_1'=>'choice_1', 'value_2'=>'choice_2');
73 $checked_choice = "value_2";
74 $class = "test_class";
76 $out = "";
77 foreach ($choices as $choice_value => $choice_label) {
78 $html_field_id = $name . '_' . $choice_value;
79 $out .= '<div class="' . $class . '">';
80 $out .= '<input type="radio" name="' . $name . '" id="' . $html_field_id . '" value="' . htmlspecialchars($choice_value) . '"';
81 if ($choice_value == $checked_choice) {
82 $out .= ' checked="checked"';
84 $out .= ' />' . "\n";
85 $out .= '<label for="' . $html_field_id . '">' . $choice_label . '</label>';
86 $out .= '<br />';
87 $out .= '</div>';
88 $out .= "\n";
91 $this->expectOutputString($out);
92 PMA_display_html_radio($name,$choices,$checked_choice,true,false,$class);
95 function testDisplayHtmlRadioWithoutBR()
97 $name = "test_display_radio";
98 $choices = array('value_1'=>'choice_1', 'value&_&lt;2&gt;'=>'choice_2');
99 $checked_choice = "choice_2";
101 $out = "";
102 foreach ($choices as $choice_value => $choice_label) {
103 $html_field_id = $name . '_' . $choice_value;
104 $out .= '<input type="radio" name="' . $name . '" id="' . $html_field_id . '" value="' . htmlspecialchars($choice_value) . '"';
105 if ($choice_value == $checked_choice) {
106 $out .= ' checked="checked"';
108 $out .= ' />' . "\n";
109 $out .= '<label for="' . $html_field_id . '">' . $choice_label . '</label>';
110 $out .= "\n";
113 $this->expectOutputString($out);
114 PMA_display_html_radio($name,$choices,$checked_choice,false);
117 function testDisplayHtmlRadioEscapeLabelEscapeLabel()
119 $name = "test_display_radio";
120 $choices = array('value_1'=>'choice_1', 'value_&2'=>'choice&_&lt;2&gt;');
121 $checked_choice = "value_2";
123 $out = "";
124 foreach ($choices as $choice_value => $choice_label) {
125 $html_field_id = $name . '_' . $choice_value;
126 $out .= '<input type="radio" name="' . $name . '" id="' . $html_field_id . '" value="' . htmlspecialchars($choice_value) . '"';
127 if ($choice_value == $checked_choice) {
128 $out .= ' checked="checked"';
130 $out .= ' />' . "\n";
131 $out .= '<label for="' . $html_field_id . '">' . htmlspecialchars($choice_label) . '</label>';
132 $out .= '<br />';
133 $out .= "\n";
136 $this->expectOutputString($out);
137 PMA_display_html_radio($name,$choices,$checked_choice,true,true);
140 function testDisplayHtmlRadioEscapeLabelNotEscapeLabel()
142 $name = "test_display_radio";
143 $choices = array('value_1'=>'choice_1', 'value_&2'=>'choice&_&lt;2&gt;');
144 $checked_choice = "value_2";
146 $out = "";
147 foreach ($choices as $choice_value => $choice_label) {
148 $html_field_id = $name . '_' . $choice_value;
149 $out .= '<input type="radio" name="' . $name . '" id="' . $html_field_id . '" value="' . htmlspecialchars($choice_value) . '"';
150 if ($choice_value == $checked_choice) {
151 $out .= ' checked="checked"';
153 $out .= ' />' . "\n";
154 $out .= '<label for="' . $html_field_id . '">' . $choice_label . '</label>';
155 $out .= '<br />';
156 $out .= "\n";
159 $this->expectOutputString($out);
160 PMA_display_html_radio($name,$choices,$checked_choice,true,false);
163 function testDisplayHtmlRadioEscapeLabelEscapeLabelWithClass()
165 $name = "test_display_radio";
166 $choices = array('value_1'=>'choice_1', 'value_&2'=>'choice&_&lt;2&gt;');
167 $checked_choice = "value_2";
168 $class = "test_class";
170 $out = "";
171 foreach ($choices as $choice_value => $choice_label) {
172 $html_field_id = $name . '_' . $choice_value;
173 $out .= '<div class="' . $class . '">';
174 $out .= '<input type="radio" name="' . $name . '" id="' . $html_field_id . '" value="' . htmlspecialchars($choice_value) . '"';
175 if ($choice_value == $checked_choice) {
176 $out .= ' checked="checked"';
178 $out .= ' />' . "\n";
179 $out .= '<label for="' . $html_field_id . '">' . htmlspecialchars($choice_label) . '</label>';
180 $out .= '<br />';
181 $out .= '</div>';
182 $out .= "\n";
185 $this->expectOutputString($out);
186 PMA_display_html_radio($name,$choices,$checked_choice,true,true,$class);