| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
echo "testing FormOptionsHelper\n"; |
|---|
| 15 |
require_once 'testenv.php'; |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
if (!defined("PHPUnit2_MAIN_METHOD")) { |
|---|
| 19 |
define("PHPUnit2_MAIN_METHOD", "FormOptionsHelperTest::main"); |
|---|
| 20 |
} |
|---|
| 21 |
|
|---|
| 22 |
require_once "PHPUnit2/Framework/TestCase.php"; |
|---|
| 23 |
require_once "PHPUnit2/Framework/TestSuite.php"; |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
require_once "PHPUnit2/Framework/IncompleteTestError.php"; |
|---|
| 27 |
|
|---|
| 28 |
require_once "action_view/helpers.php"; |
|---|
| 29 |
require_once "action_view/helpers/form_helper.php"; |
|---|
| 30 |
require_once "action_view/helpers/form_options_helper.php"; |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
class FormOptionsHelperTest extends PHPUnit2_Framework_TestCase { |
|---|
| 37 |
|
|---|
| 38 |
* Runs the test methods of this class. |
|---|
| 39 |
* |
|---|
| 40 |
* @access public |
|---|
| 41 |
* @static |
|---|
| 42 |
*/ |
|---|
| 43 |
public static function main() { |
|---|
| 44 |
require_once "PHPUnit2/TextUI/TestRunner.php"; |
|---|
| 45 |
|
|---|
| 46 |
$suite = new PHPUnit2_Framework_TestSuite("FormOptionsHelperTest"); |
|---|
| 47 |
$result = PHPUnit2_TextUI_TestRunner::run($suite); |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
* Sets up the fixture, for example, open a network connection. |
|---|
| 52 |
* This method is called before a test is executed. |
|---|
| 53 |
* |
|---|
| 54 |
* @access protected |
|---|
| 55 |
*/ |
|---|
| 56 |
protected function setUp() { |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
* Tears down the fixture, for example, close a network connection. |
|---|
| 61 |
* This method is called after a test is executed. |
|---|
| 62 |
* |
|---|
| 63 |
* @access protected |
|---|
| 64 |
*/ |
|---|
| 65 |
protected function tearDown() { |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
* @todo Write test for add_options() |
|---|
| 70 |
*/ |
|---|
| 71 |
public function testAdd_options() { |
|---|
| 72 |
|
|---|
| 73 |
throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
* @todo Write test for country_options_for_select() |
|---|
| 78 |
*/ |
|---|
| 79 |
public function testCountry_options_for_select() { |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
$fo = new FormOptionsHelper; |
|---|
| 83 |
$countries = $fo->country_options_for_select(); |
|---|
| 84 |
$this->assertContains('Bangladesh', $countries); |
|---|
| 85 |
$this->assertContains('Canada', $countries); |
|---|
| 86 |
$this->assertContains('Ecuador', $countries); |
|---|
| 87 |
$this->assertContains('France', $countries); |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
$fo = new FormOptionsHelper; |
|---|
| 91 |
$countries = $fo->country_options_for_select(17); |
|---|
| 92 |
$this->assertContains('value="17" selected="selected"', $countries); |
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 96 |
} |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
* Test the options_for_select() method |
|---|
| 100 |
*/ |
|---|
| 101 |
public function testOptions_for_select_method() { |
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
$fo = new FormOptionsHelper; |
|---|
| 105 |
$this->assertEquals('<option value="0">foo</option>' . "\n" |
|---|
| 106 |
. '<option value="1">bar</option>', |
|---|
| 107 |
$fo->options_for_select(array('foo','bar'))); |
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
$fo = new FormOptionsHelper; |
|---|
| 111 |
$this->assertEquals('<option value="0">mumble</option>' . "\n" |
|---|
| 112 |
. '<option value="1" selected="selected">grumble</option>', |
|---|
| 113 |
$fo->options_for_select(array('mumble','grumble'),1)); |
|---|
| 114 |
} |
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
* @todo Write test for options_from_collection_for_select() |
|---|
| 118 |
*/ |
|---|
| 119 |
public function testOptions_from_collection_for_select() { |
|---|
| 120 |
|
|---|
| 121 |
throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 122 |
} |
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
* @todo Write test for to_collection_select_tag() |
|---|
| 126 |
*/ |
|---|
| 127 |
public function testTo_collection_select_tag() { |
|---|
| 128 |
|
|---|
| 129 |
throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 130 |
} |
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
* @todo Write test for to_country_select_tag() |
|---|
| 134 |
*/ |
|---|
| 135 |
public function testTo_country_select_tag() { |
|---|
| 136 |
|
|---|
| 137 |
throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 138 |
} |
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
* @todo Write test for to_select_tag() |
|---|
| 142 |
*/ |
|---|
| 143 |
public function testTo_select_tag() { |
|---|
| 144 |
|
|---|
| 145 |
throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 146 |
} |
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
* @todo Write test for collection_select() |
|---|
| 150 |
*/ |
|---|
| 151 |
public function testCollection_select() { |
|---|
| 152 |
echo collection_select(null,null,null,null,null); |
|---|
| 153 |
|
|---|
| 154 |
throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 155 |
} |
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
* @todo Write test for country_select() |
|---|
| 159 |
*/ |
|---|
| 160 |
public function testCountry_select() { |
|---|
| 161 |
|
|---|
| 162 |
throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 163 |
} |
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
* Test options_for_select() function |
|---|
| 167 |
*/ |
|---|
| 168 |
public function testOptions_for_select_function() { |
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
$this->assertEquals('<option value="0">foo</option>' . "\n" |
|---|
| 172 |
. '<option value="1">bar</option>', |
|---|
| 173 |
options_for_select(array('foo','bar'))); |
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
$this->assertEquals('<option value="M">mumble</option>' . "\n" |
|---|
| 177 |
. '<option value="G" selected="selected">grumble</option>', |
|---|
| 178 |
options_for_select(array('M' => 'mumble', |
|---|
| 179 |
'G' => 'grumble'),'G')); |
|---|
| 180 |
} |
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
* @todo Write test for select() |
|---|
| 184 |
*/ |
|---|
| 185 |
public function testSelect() { |
|---|
| 186 |
|
|---|
| 187 |
throw new PHPUnit2_Framework_IncompleteTestError; |
|---|
| 188 |
} |
|---|
| 189 |
} |
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 |
if (PHPUnit2_MAIN_METHOD == "FormOptionsHelperTest::main") { |
|---|
| 193 |
FormOptionsHelperTest::main(); |
|---|
| 194 |
} |
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
|
|---|
| 203 |
?> |
|---|
| 204 |
|
|---|