2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for PMA_generate_html_dropdown_test from common.lib.php
6 * @package phpMyAdmin-test
7 * @version $Id: PMA_display_html_checkbox_test.php
8 * @group common.lib-tests
14 require_once 'libraries/common.lib.php';
16 class PMA_generate_html_dropdown_test
extends PHPUnit_Framework_TestCase
18 function testGenerateHtmlDropdownEmpty()
20 $name = "test_dropdown_name";
22 $active_choice = null;
23 $id = "test_<dropdown>_name";
25 $result = '<select name="' . htmlspecialchars($name) . '" id="' . htmlspecialchars($id) . '"></select>';
27 $this->assertEquals($result, PMA_generate_html_dropdown($name,$choices,$active_choice,$id));
30 function testGenerateHtmlDropdown()
32 $name = "&test_dropdown_name";
33 $choices = array("value_1" => "label_1", "value&_2\"" => "label_2");
34 $active_choice = null;
35 $id = "test_<dropdown>_name";
37 $result = '<select name="' . htmlspecialchars($name) . '" id="' . htmlspecialchars($id) . '">';
38 foreach ($choices as $one_choice_value => $one_choice_label) {
39 $result .= '<option value="' . htmlspecialchars($one_choice_value) . '"';
40 if ($one_choice_value == $active_choice) {
41 $result .= ' selected="selected"';
43 $result .= '>' . htmlspecialchars($one_choice_label) . '</option>';
45 $result .= '</select>';
47 $this->assertEquals($result, PMA_generate_html_dropdown($name,$choices,$active_choice,$id));
50 function testGenerateHtmlDropdownWithActive()
52 $name = "&test_dropdown_name";
53 $choices = array("value_1" => "label_1", "value&_2\"" => "label_2");
54 $active_choice = "value&_2\"";
55 $id = "test_<dropdown>_name";
57 $result = '<select name="' . htmlspecialchars($name) . '" id="' . htmlspecialchars($id) . '">';
58 foreach ($choices as $one_choice_value => $one_choice_label) {
59 $result .= '<option value="' . htmlspecialchars($one_choice_value) . '"';
60 if ($one_choice_value == $active_choice) {
61 $result .= ' selected="selected"';
63 $result .= '>' . htmlspecialchars($one_choice_label) . '</option>';
65 $result .= '</select>';
67 $this->assertEquals($result, PMA_generate_html_dropdown($name,$choices,$active_choice,$id));