InlineScriptTest.php 4.0 KB

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