/** * Initialize. * Register exit handler. */ public static function init() { self::$have_exit = FALSE; self::$first_exit_output = NULL; set_exit_overload('ExitTestHelper::exitHandler'); ob_start(); }
/** * Bug segfault while call exit in a view template * @runInSeparateProcess */ public function testCase028() { set_exit_overload(function () { return FALSE; }); $output = $this->view->render('test/exit.phtml'); $this->assertEquals('okey', trim($output)); }
protected function _overloadExit() { if (function_exists('set_exit_overload')) { set_exit_overload(function () { return false; }); return true; } elseif (function_exists('uopz_overload')) { if (!ini_get('uopz.overloads')) { $this->markTestSkipped('uopz extension installed but uopz.overloads ini setting is disabled.'); } uopz_overload(ZEND_EXIT, function () { }); return true; } return false; }
/** * 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; }