You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.2 KiB

13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
  1. <?php
  2. /**
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage Form
  7. * @since 2010-04-25
  8. * @version SVN: $Id$
  9. * @filesource $URL$
  10. */
  11. require_once dirname(__FILE__) . '/../../view/iView.php';
  12. require_once dirname(__FILE__) . '/../../view/PHPView.php';
  13. require_once dirname(__FILE__) . '/../../view/helpers/ViewHelper.php';
  14. require_once dirname(__FILE__) . '/../../form/FormViewHelper.php';
  15. require_once dirname(__FILE__) . '/../../session/Session.php';
  16. class FormViewHelperTest extends PHPUnit_Framework_TestCase
  17. {
  18. public function setUp()
  19. {
  20. Session::start();
  21. $phpview = new PHPView(array('path' => 'document_root'));
  22. $this->form = new FormViewHelper($phpview);
  23. $_SESSION['path'] = array(
  24. 'values'=>array(
  25. 'path'=>'path'
  26. ),
  27. 'messages'=>array(
  28. 'path'=>'path'
  29. )
  30. );
  31. }
  32. public function testForm2()
  33. {
  34. $this->assertNull($this->assertAttributeEquals(null, 'data', $this->form));
  35. $this->setExpectedException('Exception');
  36. $this->form->form(null);
  37. }
  38. public function testForm1()
  39. {
  40. $this->assertNull($this->assertAttributeEquals(null, 'data', $this->form)); //аналог getProp
  41. $this->form->form('path');
  42. }
  43. public function testValueIsset()
  44. {
  45. $this->form->form('path');
  46. $this->assertEquals(htmlentities('path', ENT_QUOTES, 'UTF-8'), $this->form->value('path'));
  47. }
  48. public function testValueNotIsset()
  49. {
  50. $this->form->form('path');
  51. $this->assertEquals(htmlentities('param2', ENT_QUOTES, 'UTF-8'), $this->form->value('param1','param2'));
  52. }
  53. public function testMessageIsset()
  54. {
  55. $this->form->form('path');
  56. $this->assertEquals('<span class="error">' . htmlentities('path', ENT_QUOTES, 'UTF-8') . '</span>', $this->form->message('path'));
  57. }
  58. public function testMessageNotIsset()
  59. {
  60. $this->form->form('path');
  61. $this->assertEmpty($this->form->message(''));
  62. }
  63. }