FunctionalTest.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_Layout
  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_Layout_FunctionalTest::main() if this source file is executed directly.
  23. if (!defined("PHPUnit_MAIN_METHOD")) {
  24. define("PHPUnit_MAIN_METHOD", "Zend_Layout_FunctionalTest::main");
  25. }
  26. require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';
  27. require_once 'Zend/Controller/Plugin/ErrorHandler.php';
  28. /**
  29. * @category Zend
  30. * @package Zend_Layout
  31. * @subpackage UnitTests
  32. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. * @group Zend_Layout
  35. */
  36. class Zend_Layout_FunctionalTest extends Zend_Test_PHPUnit_ControllerTestCase
  37. {
  38. /**
  39. * Runs the test methods of this class.
  40. *
  41. * @return void
  42. */
  43. public static function main()
  44. {
  45. $suite = new PHPUnit_Framework_TestSuite(__CLASS__);
  46. $result = PHPUnit_TextUI_TestRunner::run($suite);
  47. }
  48. public function setUp()
  49. {
  50. $this->bootstrap = array($this, 'appBootstrap');
  51. parent::setUp();
  52. }
  53. public function appBootstrap()
  54. {
  55. $this->frontController->setControllerDirectory(dirname(__FILE__) . '/_files/functional-test-app/controllers/');
  56. // create an instance of the ErrorHandler so we can make sure it will point to our specially named ErrorController
  57. $plugin = new Zend_Controller_Plugin_ErrorHandler();
  58. $plugin->setErrorHandlerController('zend-layout-functional-test-error')
  59. ->setErrorHandlerAction('error');
  60. $this->frontController->registerPlugin($plugin, 100);
  61. Zend_Layout::startMvc(dirname(__FILE__) . '/_files/functional-test-app/layouts/');
  62. }
  63. public function testMissingViewScriptDoesNotDoubleRender()
  64. {
  65. // go to the test controller for this funcitonal test
  66. $this->dispatch('/zend-layout-functional-test-test/missing-view-script');
  67. $this->assertEquals(trim($this->response->getBody()), "[DEFAULT_LAYOUT_START]\n(ErrorController::errorAction output)[DEFAULT_LAYOUT_END]");
  68. }
  69. public function testMissingViewScriptDoesDoubleRender()
  70. {
  71. Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-91, new Zend_Controller_Action_Helper_ViewRenderer());
  72. // go to the test controller for this funcitonal test
  73. $this->dispatch('/zend-layout-functional-test-test/missing-view-script');
  74. $this->assertEquals(trim($this->response->getBody()), "[DEFAULT_LAYOUT_START]\n[DEFAULT_LAYOUT_START]\n[DEFAULT_LAYOUT_END]\n(ErrorController::errorAction output)[DEFAULT_LAYOUT_END]");
  75. }
  76. }
  77. // Call Zend_Layout_FunctionalTest::main() if this source file is executed directly.
  78. if (PHPUnit_MAIN_METHOD == "Zend_Layout_FunctionalTest::main") {
  79. Zend_Layout_FunctionalTest::main();
  80. }