InlineScriptTest.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. // Call Zend_View_Helper_InlineScriptTest::main() if this source file is executed directly.
  23. if (!defined("PHPUnit_MAIN_METHOD")) {
  24. define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_InlineScriptTest::main");
  25. }
  26. /** Zend_View_Helper_InlineScript */
  27. require_once 'Zend/View/Helper/InlineScript.php';
  28. /** Zend_View_Helper_Placeholder_Registry */
  29. require_once 'Zend/View/Helper/Placeholder/Registry.php';
  30. /** Zend_Registry */
  31. require_once 'Zend/Registry.php';
  32. /**
  33. * Test class for Zend_View_Helper_InlineScript.
  34. *
  35. * @category Zend
  36. * @package Zend_View
  37. * @subpackage UnitTests
  38. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  39. * @license http://framework.zend.com/license/new-bsd New BSD License
  40. * @group Zend_View
  41. * @group Zend_View_Helper
  42. */
  43. class Zend_View_Helper_InlineScriptTest extends PHPUnit_Framework_TestCase
  44. {
  45. /**
  46. * @var Zend_View_Helper_InlineScript
  47. */
  48. public $helper;
  49. /**
  50. * @var string
  51. */
  52. public $basePath;
  53. /**
  54. * Runs the test methods of this class.
  55. *
  56. * @return void
  57. */
  58. public static function main()
  59. {
  60. $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_InlineScriptTest");
  61. $result = PHPUnit_TextUI_TestRunner::run($suite);
  62. }
  63. /**
  64. * Sets up the fixture, for example, open a network connection.
  65. * This method is called before a test is executed.
  66. *
  67. * @return void
  68. */
  69. public function setUp()
  70. {
  71. $regKey = Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY;
  72. if (Zend_Registry::isRegistered($regKey)) {
  73. $registry = Zend_Registry::getInstance();
  74. unset($registry[$regKey]);
  75. }
  76. $this->basePath = dirname(__FILE__) . '/_files/modules';
  77. $this->helper = new Zend_View_Helper_InlineScript();
  78. }
  79. /**
  80. * Tears down the fixture, for example, close a network connection.
  81. * This method is called after a test is executed.
  82. *
  83. * @return void
  84. */
  85. public function tearDown()
  86. {
  87. unset($this->helper);
  88. }
  89. public function testNamespaceRegisteredInPlaceholderRegistryAfterInstantiation()
  90. {
  91. $registry = Zend_View_Helper_Placeholder_Registry::getRegistry();
  92. if ($registry->containerExists('Zend_View_Helper_InlineScript')) {
  93. $registry->deleteContainer('Zend_View_Helper_InlineScript');
  94. }
  95. $this->assertFalse($registry->containerExists('Zend_View_Helper_InlineScript'));
  96. $helper = new Zend_View_Helper_InlineScript();
  97. $this->assertTrue($registry->containerExists('Zend_View_Helper_InlineScript'));
  98. }
  99. public function testInlineScriptReturnsObjectInstance()
  100. {
  101. $placeholder = $this->helper->inlineScript();
  102. $this->assertTrue($placeholder instanceof Zend_View_Helper_InlineScript);
  103. }
  104. }
  105. // Call Zend_View_Helper_InlineScriptTest::main() if this source file is executed directly.
  106. if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_InlineScriptTest::main") {
  107. Zend_View_Helper_InlineScriptTest::main();
  108. }