InlineScriptTest.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. // Call Zend_View_Helper_InlineScriptTest::main() if this source file is executed directly.
  3. if (!defined("PHPUnit_MAIN_METHOD")) {
  4. define("PHPUnit_MAIN_METHOD", "Zend_View_Helper_InlineScriptTest::main");
  5. }
  6. require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/TestHelper.php';
  7. require_once "PHPUnit/Framework/TestCase.php";
  8. require_once "PHPUnit/Framework/TestSuite.php";
  9. /** Zend_View_Helper_InlineScript */
  10. require_once 'Zend/View/Helper/InlineScript.php';
  11. /** Zend_View_Helper_Placeholder_Registry */
  12. require_once 'Zend/View/Helper/Placeholder/Registry.php';
  13. /** Zend_Registry */
  14. require_once 'Zend/Registry.php';
  15. /**
  16. * Test class for Zend_View_Helper_InlineScript.
  17. *
  18. * @category Zend
  19. * @package Zend_View
  20. * @subpackage UnitTests
  21. */
  22. class Zend_View_Helper_InlineScriptTest extends PHPUnit_Framework_TestCase
  23. {
  24. /**
  25. * @var Zend_View_Helper_InlineScript
  26. */
  27. public $helper;
  28. /**
  29. * @var string
  30. */
  31. public $basePath;
  32. /**
  33. * Runs the test methods of this class.
  34. *
  35. * @return void
  36. */
  37. public static function main()
  38. {
  39. require_once "PHPUnit/TextUI/TestRunner.php";
  40. $suite = new PHPUnit_Framework_TestSuite("Zend_View_Helper_InlineScriptTest");
  41. $result = PHPUnit_TextUI_TestRunner::run($suite);
  42. }
  43. /**
  44. * Sets up the fixture, for example, open a network connection.
  45. * This method is called before a test is executed.
  46. *
  47. * @return void
  48. */
  49. public function setUp()
  50. {
  51. $regKey = Zend_View_Helper_Placeholder_Registry::REGISTRY_KEY;
  52. if (Zend_Registry::isRegistered($regKey)) {
  53. $registry = Zend_Registry::getInstance();
  54. unset($registry[$regKey]);
  55. }
  56. $this->basePath = dirname(__FILE__) . '/_files/modules';
  57. $this->helper = new Zend_View_Helper_InlineScript();
  58. }
  59. /**
  60. * Tears down the fixture, for example, close a network connection.
  61. * This method is called after a test is executed.
  62. *
  63. * @return void
  64. */
  65. public function tearDown()
  66. {
  67. unset($this->helper);
  68. }
  69. public function testNamespaceRegisteredInPlaceholderRegistryAfterInstantiation()
  70. {
  71. $registry = Zend_View_Helper_Placeholder_Registry::getRegistry();
  72. if ($registry->containerExists('Zend_View_Helper_InlineScript')) {
  73. $registry->deleteContainer('Zend_View_Helper_InlineScript');
  74. }
  75. $this->assertFalse($registry->containerExists('Zend_View_Helper_InlineScript'));
  76. $helper = new Zend_View_Helper_InlineScript();
  77. $this->assertTrue($registry->containerExists('Zend_View_Helper_InlineScript'));
  78. }
  79. public function testInlineScriptReturnsObjectInstance()
  80. {
  81. $placeholder = $this->helper->inlineScript();
  82. $this->assertTrue($placeholder instanceof Zend_View_Helper_InlineScript);
  83. }
  84. }
  85. // Call Zend_View_Helper_InlineScriptTest::main() if this source file is executed directly.
  86. if (PHPUnit_MAIN_METHOD == "Zend_View_Helper_InlineScriptTest::main") {
  87. Zend_View_Helper_InlineScriptTest::main();
  88. }