本文整理汇总了PHP中RedBeanPHP\Facade::setErrorHandlingFUSE方法的典型用法代码示例。如果您正苦于以下问题:PHP Facade::setErrorHandlingFUSE方法的具体用法?PHP Facade::setErrorHandlingFUSE怎么用?PHP Facade::setErrorHandlingFUSE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanPHP\Facade
的用法示例。
在下文中一共展示了Facade::setErrorHandlingFUSE方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testToStringIssue512
/**
* Test fix for issue #512 - thanks for reporting Bernhard H.
* OODBBean::__toString() implementation only works with C_ERR_IGNORE
*
* @return void
*/
public function testToStringIssue512()
{
R::setErrorHandlingFUSE(\RedBeanPHP\OODBBean::C_ERR_FATAL);
$boxedBean = R::dispense('boxedbean');
$str = (string) $boxedBean;
asrt($str, '{"id":0}');
//no fatal error
R::setErrorHandlingFUSE(FALSE);
}
示例2: testModelErrorHandling
/**
* Test error handling options FUSE.
*/
public function testModelErrorHandling()
{
$test = R::dispense('feed');
$test->nonExistantMethod();
pass();
$old = R::setErrorHandlingFUSE(OODBBean::C_ERR_LOG);
asrt(is_array($old), TRUE);
asrt(count($old), 2);
asrt($old[0], FALSE);
asrt($old[1], NULL);
$test->nonExistantMethod();
//we cant really test this... :(
pass();
$old = R::setErrorHandlingFUSE(OODBBean::C_ERR_NOTICE);
asrt(is_array($old), TRUE);
asrt(count($old), 2);
asrt($old[0], OODBBean::C_ERR_LOG);
asrt($old[1], NULL);
set_error_handler(function ($error, $str) {
asrt($str, 'FUSE: method does not exist in model: nonExistantMethod');
}, E_USER_NOTICE);
$test->nonExistantMethod();
restore_error_handler();
$old = OODBBean::setErrorHandlingFUSE(OODBBean::C_ERR_WARN);
asrt(is_array($old), TRUE);
asrt(count($old), 2);
asrt($old[0], OODBBean::C_ERR_NOTICE);
asrt($old[1], NULL);
set_error_handler(function ($error, $str) {
asrt($str, 'FUSE: method does not exist in model: nonExistantMethod');
}, E_USER_WARNING);
$test->nonExistantMethod();
restore_error_handler();
$old = OODBBean::setErrorHandlingFUSE(OODBBean::C_ERR_FATAL);
asrt(is_array($old), TRUE);
asrt(count($old), 2);
asrt($old[0], OODBBean::C_ERR_WARN);
asrt($old[1], NULL);
set_error_handler(function ($error, $str) {
asrt($str, 'FUSE: method does not exist in model: nonExistantMethod');
}, E_USER_ERROR);
$test->nonExistantMethod();
restore_error_handler();
$old = OODBBean::setErrorHandlingFUSE(OODBBean::C_ERR_EXCEPTION);
asrt(is_array($old), TRUE);
asrt(count($old), 2);
asrt($old[0], OODBBean::C_ERR_FATAL);
asrt($old[1], NULL);
try {
$test->nonExistantMethod();
fail();
} catch (\Exception $e) {
pass();
}
global $test_bean;
$test_bean = $test;
global $has_executed_error_func_fuse;
$has_executed_error_func_fuse = FALSE;
$old = OODBBean::setErrorHandlingFUSE(OODBBean::C_ERR_FUNC, function ($info) {
global $has_executed_error_func_fuse;
global $test_bean;
$has_executed_error_func_fuse = TRUE;
asrt(is_array($info), TRUE);
asrt($info['method'], 'nonExistantMethod');
asrt(json_encode($info['bean']->export()), json_encode($test_bean->export()));
asrt($info['message'], 'FUSE: method does not exist in model: nonExistantMethod');
});
asrt(is_array($old), TRUE);
asrt(count($old), 2);
asrt($old[0], OODBBean::C_ERR_EXCEPTION);
asrt($old[1], NULL);
$test->nonExistantMethod();
asrt($has_executed_error_func_fuse, TRUE);
$old = OODBBean::setErrorHandlingFUSE(OODBBean::C_ERR_IGNORE);
asrt(is_array($old), TRUE);
asrt(count($old), 2);
asrt($old[0], OODBBean::C_ERR_FUNC);
asrt(is_callable($old[1]), TRUE);
$old = OODBBean::setErrorHandlingFUSE(OODBBean::C_ERR_IGNORE);
asrt(is_array($old), TRUE);
asrt(count($old), 2);
asrt($old[0], OODBBean::C_ERR_IGNORE);
asrt($old[1], NULL);
try {
OODBBean::setErrorHandlingFUSE(900);
fail();
} catch (\Exception $e) {
pass();
asrt($e->getMessage(), 'Invalid error mode selected');
}
try {
OODBBean::setErrorHandlingFUSE(OODBBean::C_ERR_FUNC, 'hello');
fail();
} catch (\Exception $e) {
pass();
asrt($e->getMessage(), 'Invalid error handler');
}
//.........这里部分代码省略.........