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.

83 lines
2.3 KiB

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__) . '/../../form/Form.php';
  12. require_once dirname(__FILE__) . '/../../form/FormField.php';
  13. require_once dirname(__FILE__) . '/../../view/iView.php';
  14. require_once dirname(__FILE__) . '/../../view/PHPView.php';
  15. require_once dirname(__FILE__) . '/../../view/helpers/ViewHelper.php';
  16. require_once dirname(__FILE__) . '/../../form/FormViewHelper.php';
  17. require_once dirname(__FILE__) . '/../../session/Session.php';
  18. class FormViewHelperTest extends PHPUnit_Framework_TestCase
  19. {
  20. public function setUp()
  21. {
  22. Session::start();
  23. $phpview = new PHPView(array('path' => 'document_root'));
  24. $this->form = new FormViewHelper($phpview);
  25. $_SESSION['path'] = array(
  26. 'values'=>array(
  27. 'path'=>'path'
  28. ),
  29. 'messages'=>array(
  30. 'path'=>'path'
  31. )
  32. );
  33. }
  34. public function testForm2()
  35. {
  36. $this->assertNull($this->assertAttributeEquals(null,'data',$this->form));
  37. $this->setExpectedException('Exception');
  38. $this->form->form(null);
  39. }
  40. public function testForm1()
  41. {
  42. $this->assertNull($this->assertAttributeEquals(null,'data',$this->form)); //аналог getProp
  43. $this->form->form('path');
  44. }
  45. public function testValueIsset()
  46. {
  47. $this->form->form('path');
  48. $this->assertEquals('path', $this->form->value('path'));
  49. }
  50. public function testValueNotIsset()
  51. {
  52. $this->form->form('path');
  53. $this->assertEquals('param2', $this->form->value('param1','param2'));
  54. }
  55. public function testMessageIsset()
  56. {
  57. $this->form->form('path');
  58. $this->assertNotEmpty($this->form->message('path'));
  59. }
  60. public function testMessageNotIsset()
  61. {
  62. $this->form->form('path');
  63. $this->assertEmpty($this->form->message(''));
  64. }
  65. }