HelperBrokerController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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_Controller
  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. require_once 'Zend/Controller/Action.php';
  23. /**
  24. * Mock file for testbed
  25. *
  26. * @category Zend
  27. * @package Zend_Controller
  28. * @subpackage UnitTests
  29. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. */
  32. class HelperBrokerController extends Zend_Controller_Action
  33. {
  34. /**
  35. * Test Function for testGetRedirectorAction
  36. *
  37. * @return void
  38. */
  39. public function testGetRedirectorAction()
  40. {
  41. $redirector = $this->_helper->getHelper('Redirector');
  42. $this->getResponse()->appendBody(get_class($redirector));
  43. }
  44. /**
  45. * Test Function for testHelperViaMagicGetAction
  46. *
  47. * @return void
  48. */
  49. public function testHelperViaMagicGetAction()
  50. {
  51. $redirector = $this->_helper->Redirector;
  52. $this->getResponse()->appendBody(get_class($redirector));
  53. }
  54. /**
  55. * Test Function for testHelperViaMagicCallAction
  56. *
  57. * @return void
  58. */
  59. public function testHelperViaMagicCallAction()
  60. {
  61. $this->getResponse()->appendBody($this->_helper->TestHelper());
  62. }
  63. /**
  64. * Test Function for testBadHelperAction
  65. *
  66. * @return void
  67. */
  68. public function testBadHelperAction()
  69. {
  70. try {
  71. $this->_helper->getHelper('NonExistentHelper');
  72. } catch (Exception $e) {
  73. $this->getResponse()->appendBody($e->getMessage());
  74. }
  75. }
  76. /**
  77. * Test Function for testCustomHelperAction
  78. *
  79. * @return void
  80. */
  81. public function testCustomHelperAction()
  82. {
  83. $this->getResponse()->appendBody(get_class($this->_helper->TestHelper));
  84. }
  85. public function testCanLoadNamespacedHelperAction()
  86. {
  87. try {
  88. $helper = $this->_helper->getHelper('NamespacedHelper');
  89. $this->getResponse()->appendBody(get_class($helper));
  90. } catch (Exception $e) {
  91. $this->getResponse()->appendBody($e->getMessage());
  92. }
  93. }
  94. }