PHPonTraxTest
[ class tree: PHPonTraxTest ] [ index: PHPonTraxTest ] [ all elements ]

Source for file FormOptionsHelperTest.php

Documentation is available at FormOptionsHelperTest.php

  1. <?php
  2. /**
  3. * File for the FormOptionsHelperTest class
  4. *
  5. * (PHP 5)
  6. *
  7. * @package PHPonTraxTest
  8. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  9. * @copyright (c) Walter O. Haas 2006
  10. * @version $Id: FormOptionsHelperTest.php 198 2006-04-20 16:20:30Z haas $
  11. * @author Walt Haas <haas@xmission.com>
  12. */
  13.  
  14. echo "testing FormOptionsHelper\n";
  15. require_once 'testenv.php';
  16.  
  17. // Call FormOptionsHelperTest::main() if this source file is executed directly.
  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. // You may remove the following line when all tests have been implemented.
  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. * Test class for FormOptionsHelper.
  34. * Generated by PHPUnit2_Util_Skeleton on 2006-03-01 at 13:17:32.
  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. // Remove the following line when you implement this test.
  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. // Spot check a few countries
  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. // Select a country
  90. $fo = new FormOptionsHelper;
  91. $countries = $fo->country_options_for_select(17);
  92. $this->assertContains('value="17" selected="selected"', $countries);
  93.  
  94. // Remove the following line when you implement this test.
  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. // Test choices with none selected
  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. // Test choices with one selected
  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. // Remove the following line when you implement this test.
  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. // Remove the following line when you implement this test.
  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. // Remove the following line when you implement this test.
  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. // Remove the following line when you implement this test.
  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. // Remove the following line when you implement this test.
  154. throw new PHPUnit2_Framework_IncompleteTestError;
  155. }
  156.  
  157. /**
  158. * @todo Write test for country_select()
  159. */
  160. public function testCountry_select() {
  161. // Remove the following line when you implement this test.
  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. // Test choices with none selected
  171. $this->assertEquals('<option value="0">foo</option>' . "\n"
  172. . '<option value="1">bar</option>',
  173. options_for_select(array('foo','bar')));
  174.  
  175. // Test choices with one selected by key
  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. // Remove the following line when you implement this test.
  187. throw new PHPUnit2_Framework_IncompleteTestError;
  188. }
  189. }
  190.  
  191. // Call FormOptionsHelperTest::main() if this source file is executed directly.
  192. if (PHPUnit2_MAIN_METHOD == "FormOptionsHelperTest::main") {
  193. FormOptionsHelperTest::main();
  194. }
  195.  
  196. // -- set Emacs parameters --
  197. // Local variables:
  198. // tab-width: 4
  199. // c-basic-offset: 4
  200. // c-hanging-comment-ender-p: nil
  201. // indent-tabs-mode: nil
  202. // End:
  203. ?>

Documentation generated on Thu, 04 May 2006 19:47:35 -0600 by phpDocumentor 1.3.0RC4