2
0

FunctionalTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. // Call Zend_Layout_FunctionalTest::main() if this source file is executed directly.
  3. if (!defined("PHPUnit_MAIN_METHOD")) {
  4. define("PHPUnit_MAIN_METHOD", "Zend_Layout_FunctionalTest::main");
  5. }
  6. require_once dirname(__FILE__) . '/../../TestHelper.php';
  7. require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';
  8. require_once 'Zend/Controller/Plugin/ErrorHandler.php';
  9. class Zend_Layout_FunctionalTest extends Zend_Test_PHPUnit_ControllerTestCase
  10. {
  11. /**
  12. * Runs the test methods of this class.
  13. *
  14. * @return void
  15. */
  16. public static function main()
  17. {
  18. require_once "PHPUnit/TextUI/TestRunner.php";
  19. $suite = new PHPUnit_Framework_TestSuite(__CLASS__);
  20. $result = PHPUnit_TextUI_TestRunner::run($suite);
  21. }
  22. public function setUp()
  23. {
  24. $this->bootstrap = array($this, 'appBootstrap');
  25. parent::setUp();
  26. }
  27. public function appBootstrap()
  28. {
  29. $this->frontController->setControllerDirectory(dirname(__FILE__) . '/_files/functional-test-app/controllers/');
  30. // create an instance of the ErrorHandler so we can make sure it will point to our specially named ErrorController
  31. $plugin = new Zend_Controller_Plugin_ErrorHandler();
  32. $plugin->setErrorHandlerController('zend-layout-functional-test-error')
  33. ->setErrorHandlerAction('error');
  34. $this->frontController->registerPlugin($plugin, 100);
  35. Zend_Layout::startMvc(dirname(__FILE__) . '/_files/functional-test-app/layouts/');
  36. }
  37. public function testMissingViewScriptDoesNotDoubleRender()
  38. {
  39. // go to the test controller for this funcitonal test
  40. $this->dispatch('/zend-layout-functional-test-test/missing-view-script');
  41. $this->assertEquals(trim($this->response->getBody()), "[DEFAULT_LAYOUT_START]\n(ErrorController::errorAction output)[DEFAULT_LAYOUT_END]");
  42. }
  43. public function testMissingViewScriptDoesDoubleRender()
  44. {
  45. Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-91, new Zend_Controller_Action_Helper_ViewRenderer());
  46. // go to the test controller for this funcitonal test
  47. $this->dispatch('/zend-layout-functional-test-test/missing-view-script');
  48. $this->assertEquals(trim($this->response->getBody()), "[DEFAULT_LAYOUT_START]\n[DEFAULT_LAYOUT_START]\n[DEFAULT_LAYOUT_END]\n(ErrorController::errorAction output)[DEFAULT_LAYOUT_END]");
  49. }
  50. }
  51. // Call Zend_Layout_FunctionalTest::main() if this source file is executed directly.
  52. if (PHPUnit_MAIN_METHOD == "Zend_Layout_FunctionalTest::main") {
  53. Zend_Layout_FunctionalTest::main();
  54. }