2
0

FunctionalTest.php 3.5 KB

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