PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/Zend/View/Helper/FieldsetTest.php

https://bitbucket.org/dbaltas/zend-framework-1.x-on-git
PHP | 119 lines | 52 code | 11 blank | 56 comment | 3 complexity | 8c53529629007566c0ed1dc44c0c6831 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0, MIT
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_View
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: FieldsetTest.php 24593 2012-01-05 20:35:02Z matthew $
  21. */
  22. // Call Zend_FieldsetTest::main() if this source file is executed directly.
  23. if (!defined("PHPUnit_MAIN_METHOD")) {
  24. define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_FieldsetTest::main");
  25. }
  26. require_once 'Zend/View/Helper/Fieldset.php';
  27. require_once 'Zend/View.php';
  28. /**
  29. * Test class for Zend_View_Helper_Fieldset
  30. *
  31. * @category Zend
  32. * @package Zend_View
  33. * @subpackage UnitTests
  34. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. * @group Zend_View
  37. * @group Zend_View_Helper
  38. */
  39. class Zend_View_Helper_FieldsetTest extends PHPUnit_Framework_TestCase
  40. {
  41. /**
  42. * Runs the test methods of this class.
  43. *
  44. * @return void
  45. */
  46. public static function main()
  47. {
  48. $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_FieldsetTest");
  49. $result = PHPUnit_TextUI_TestRunner::run($suite);
  50. }
  51. /**
  52. * Sets up the fixture, for example, open a network connection.
  53. * This method is called before a test is executed.
  54. *
  55. * @return void
  56. */
  57. public function setUp()
  58. {
  59. $this->view = new Zend_View();
  60. $this->helper = new Zend_View_Helper_Fieldset();
  61. $this->helper->setView($this->view);
  62. ob_start();
  63. }
  64. /**
  65. * Tears down the fixture, for example, close a network connection.
  66. * This method is called after a test is executed.
  67. *
  68. * @return void
  69. */
  70. public function tearDown()
  71. {
  72. ob_end_clean();
  73. }
  74. public function testFieldsetHelperCreatesFieldsetWithProvidedContent()
  75. {
  76. $html = $this->helper->fieldset('foo', 'foobar');
  77. $this->assertRegexp('#<fieldset[^>]+id="foo".*?>#', $html);
  78. $this->assertContains('</fieldset>', $html);
  79. $this->assertContains('foobar', $html);
  80. }
  81. public function testProvidingLegendOptionToFieldsetCreatesLegendTag()
  82. {
  83. $html = $this->helper->fieldset('foo', 'foobar', array('legend' => 'Great Scott!'));
  84. $this->assertRegexp('#<legend>Great Scott!</legend>#', $html);
  85. }
  86. /**
  87. * @group ZF-2913
  88. */
  89. public function testEmptyLegendShouldNotRenderLegendTag()
  90. {
  91. foreach (array(null, '', ' ', false) as $legend) {
  92. $html = $this->helper->fieldset('foo', 'foobar', array('legend' => $legend));
  93. $this->assertNotContains('<legend>', $html, 'Failed with value ' . var_export($legend, 1) . ': ' . $html);
  94. }
  95. }
  96. /**
  97. * @group ZF-3632
  98. */
  99. public function testHelperShouldAllowDisablingEscapingOfLegend()
  100. {
  101. $html = $this->helper->fieldset('foo', 'foobar', array('legend' => '<b>Great Scott!</b>', 'escape' => false));
  102. $this->assertRegexp('#<legend><b>Great Scott!</b></legend>#', $html, $html);
  103. }
  104. }
  105. // Call Zend_View_Helper_FieldsetTest::main() if this source file is executed directly.
  106. if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_FieldsetTest::main") {
  107. Zend_View_Helper_FieldsetTest::main();
  108. }