예제 #1
0
 /**
  * Clean up.
  * Unregister exit handler.
  */
 public static function clean()
 {
     ob_end_clean();
     unset_exit_overload();
     self::$have_exit = FALSE;
     self::$first_exit_output = NULL;
 }
 protected function _restoreExit()
 {
     if (function_exists('unset_exit_overload')) {
         unset_exit_overload();
     } elseif (function_exists('uopz_overload')) {
         uopz_overload(ZEND_EXIT, null);
     }
 }
 /**
  * Requires phpunit/test_helpers to be installed so exit() can be overloaded.
  *
  * See https://github.com/sebastianbergmann/php-test-helpers
  * and https://github.com/whatthejeff/php-test-helpers (a pull request so it compiles for PHP 5.4)
  *
  * @param string $route
  * @throws Exception|Zend_Controller_Response_Exception
  * @return string
  */
 protected function getResponseFromActionWithExit($route)
 {
     $responseBody = '';
     if (function_exists('set_exit_overload')) {
         try {
             set_exit_overload(function () {
                 return false;
             });
             ob_start();
             $this->dispatch($route);
         } catch (Zend_Controller_Response_Exception $e) {
             if ($e->getMessage() !== 'Cannot send headers; headers already sent') {
                 unset_exit_overload();
                 throw $e;
             }
         }
         unset_exit_overload();
         $responseBody = ob_get_contents();
         ob_end_clean();
     } else {
         $this->markTestSkipped("phpunit/test_helpers with set_exit_overload() not installed.");
     }
     return $responseBody;
 }