PageRenderTime 45ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/test/Plugin/Smarty/Plugin_Smarty_function_select_Test.php

http://github.com/ethna/ethna
PHP | 56 lines | 35 code | 5 blank | 16 comment | 0 complexity | c9a9f5d5f826d893a447abcc042d6c7f MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4. * Plugin_Smarty_function_select_Test.php
  5. *
  6. * @author Yoshinari Takaoka <takaoka@beatcraft.com>
  7. * @version $Id: ea3bf5ec320f15fb83fa4f773a78444606c9a6a6 $
  8. */
  9. require_once ETHNA_BASE . '/class/Plugin/Smarty/function.select.php';
  10. //{{{ Ethna_Plugin_Smarty_function_select_Test
  11. /**
  12. * Test Case For function.select.php
  13. *
  14. * @access public
  15. */
  16. class Ethna_Plugin_Smarty_function_select_Test extends Ethna_UnitTestBase
  17. {
  18. // {{{ test_smarty_function_select
  19. function test_smarty_function_select()
  20. {
  21. $params = array('list' => array(
  22. '1' => array('name' => 'foo'),
  23. 'value' => array('name' => 'bar'),
  24. ),
  25. 'name' => 'name',
  26. 'value' => 'value',
  27. 'empty' => false,
  28. );
  29. $dummy_smarty = null;
  30. $expected = "<select name=\"name\">\n"
  31. . "<option value=\"1\" >foo</option>\n"
  32. . "<option value=\"value\" selected=\"selected\">bar</option>\n"
  33. . "</select>\n";
  34. ob_start();
  35. smarty_function_select($params, $dummy_smarty);
  36. $actual = ob_get_clean();
  37. $this->assertEqual($expected, $actual);
  38. $params['empty'] = '-- please select --';
  39. $expected = "<select name=\"name\">\n"
  40. . "<option value=\"\">-- please select --</option>\n"
  41. . "<option value=\"1\" >foo</option>\n"
  42. . "<option value=\"value\" selected=\"selected\">bar</option>\n"
  43. . "</select>\n";
  44. ob_start();
  45. smarty_function_select($params, $dummy_smarty);
  46. $actual = ob_get_clean();
  47. $this->assertEqual($expected, $actual);
  48. }
  49. // }}}
  50. }
  51. // }}}