Skip to content

Commit

Permalink
add tests for user_error_handler
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Sep 27, 2012
1 parent afbe05c commit 8c5222c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
66 changes: 66 additions & 0 deletions tests/060.phpt
@@ -0,0 +1,66 @@
--TEST--
Check nesting view render
--SKIPIF--
<?php if (!extension_loaded("yaf")) print "skip"; ?>
--INI--
yaf.use_spl_autoload=1
yaf.lowcase_path=0
--XFAIL--
We can not suppress EG(user_error_handler) for now
--FILE--
<?php
require "build.inc";
startup();

function my_autoload($class) {
eval("class $class {}");
return TRUE;
}

$config = array(
"application" => array(
"directory" => APPLICATION_PATH,
),
);

file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<<PHP
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract {
public function _initAutoload(Yaf_Dispatcher \$dispatcher) {
spl_autoload_register("my_autoload");
}
public static function errorHandler(\$error, \$errstr) {
var_dump(\$errstr);
}
public function _initErrorHandler(Yaf_Dispatcher \$dispatcher) {
\$dispatcher->setErrorHandler(array("Bootstrap", "errorHandler"));
}
}
PHP
);

file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<<PHP
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
\$obj = new Dummy();
\$this->_view->obj = \$obj;
}
}
PHP
);

file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "<?php echo get_class(\$obj);?>");

$app = new Yaf_Application($config);
$response = $app->bootstrap()->run();
?>
--CLEAN--
<?php
require "build.inc";
shutdown();
?>
--EXPECTF--
Dummy
3 changes: 2 additions & 1 deletion yaf_loader.c
Expand Up @@ -14,7 +14,7 @@
+----------------------------------------------------------------------+
*/

/* $Id: yaf_loader.c 327707 2012-09-20 10:05:55Z laruence $ */
/* $Id: yaf_loader.c 327825 2012-09-27 14:19:55Z laruence $ */

#ifdef HAVE_CONFIG_H
#include "config.h"
Expand Down Expand Up @@ -374,6 +374,7 @@ int yaf_loader_import(char *path, int len, int use_path TSRMLS_DC) {
file_handle.opened_path = NULL;
file_handle.handle.fp = NULL;

/* we do such trick for performance issue */
if (!zend_origin_error_handler) {
restore_cb = 1;
zend_origin_error_handler = zend_error_cb;
Expand Down

0 comments on commit 8c5222c

Please sign in to comment.