PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/zendframework/zf2
PHP | 102 lines | 42 code | 9 blank | 51 comment | 0 complexity | a9df85bfdba8f126ded7f210c8b5f264 MD5 | raw file
Possible License(s): BSD-3-Clause
  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. */
  21. /**
  22. * @namespace
  23. */
  24. namespace ZendTest\View\Helper;
  25. use Zend\View\PhpRenderer as View,
  26. Zend\View\Helper\Fieldset;
  27. /**
  28. * Test class for Zend_View_Helper_Fieldset
  29. *
  30. * @category Zend
  31. * @package Zend_View
  32. * @subpackage UnitTests
  33. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. * @group Zend_View
  36. * @group Zend_View_Helper
  37. */
  38. class FieldsetTest extends \PHPUnit_Framework_TestCase
  39. {
  40. /**
  41. * Sets up the fixture, for example, open a network connection.
  42. * This method is called before a test is executed.
  43. *
  44. * @return void
  45. */
  46. public function setUp()
  47. {
  48. $this->view = new View();
  49. $this->helper = new Fieldset();
  50. $this->helper->setView($this->view);
  51. ob_start();
  52. }
  53. /**
  54. * Tears down the fixture, for example, close a network connection.
  55. * This method is called after a test is executed.
  56. *
  57. * @return void
  58. */
  59. public function tearDown()
  60. {
  61. ob_end_clean();
  62. }
  63. public function testFieldsetHelperCreatesFieldsetWithProvidedContent()
  64. {
  65. $html = $this->helper->__invoke('foo', 'foobar');
  66. $this->assertRegexp('#<fieldset[^>]+id="foo".*?>#', $html);
  67. $this->assertContains('</fieldset>', $html);
  68. $this->assertContains('foobar', $html);
  69. }
  70. public function testProvidingLegendOptionToFieldsetCreatesLegendTag()
  71. {
  72. $html = $this->helper->__invoke('foo', 'foobar', array('legend' => 'Great Scott!'));
  73. $this->assertRegexp('#<legend>Great Scott!</legend>#', $html);
  74. }
  75. /**
  76. * @group ZF-2913
  77. */
  78. public function testEmptyLegendShouldNotRenderLegendTag()
  79. {
  80. foreach (array(null, '', ' ', false) as $legend) {
  81. $html = $this->helper->__invoke('foo', 'foobar', array('legend' => $legend));
  82. $this->assertNotContains('<legend>', $html, 'Failed with value ' . var_export($legend, 1) . ': ' . $html);
  83. }
  84. }
  85. /**
  86. * @group ZF-3632
  87. */
  88. public function testHelperShouldAllowDisablingEscapingOfLegend()
  89. {
  90. $html = $this->helper->__invoke('foo', 'foobar', array('legend' => '<b>Great Scott!</b>', 'escape' => false));
  91. $this->assertRegexp('#<legend><b>Great Scott!</b></legend>#', $html, $html);
  92. }
  93. }