本文整理汇总了PHP中phpunit_util::is_redirecting_messages方法的典型用法代码示例。如果您正苦于以下问题:PHP phpunit_util::is_redirecting_messages方法的具体用法?PHP phpunit_util::is_redirecting_messages怎么用?PHP phpunit_util::is_redirecting_messages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpunit_util
的用法示例。
在下文中一共展示了phpunit_util::is_redirecting_messages方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: message_send
//.........这里部分代码省略.........
$savemessage->component = $eventdata->component;
if (!empty($eventdata->contexturl)) {
$savemessage->contexturl = (string)$eventdata->contexturl;
} else {
$savemessage->contexturl = null;
}
if (!empty($eventdata->contexturlname)) {
$savemessage->contexturlname = (string)$eventdata->contexturlname;
} else {
$savemessage->contexturlname = null;
}
$savemessage->timecreated = time();
if (PHPUNIT_TEST and class_exists('phpunit_util')) {
// Add some more tests to make sure the normal code can actually work.
$componentdir = core_component::get_component_directory($eventdata->component);
if (!$componentdir or !is_dir($componentdir)) {
throw new coding_exception('Invalid component specified in message-send(): '.$eventdata->component);
}
if (!file_exists("$componentdir/db/messages.php")) {
throw new coding_exception("$eventdata->component does not contain db/messages.php necessary for message_send()");
}
$messageproviders = null;
include("$componentdir/db/messages.php");
if (!isset($messageproviders[$eventdata->name])) {
throw new coding_exception("Missing messaging defaults for event '$eventdata->name' in '$eventdata->component' messages.php file");
}
unset($componentdir);
unset($messageproviders);
// Now ask phpunit if it wants to catch this message.
if (phpunit_util::is_redirecting_messages()) {
$savemessage->timeread = time();
$messageid = $DB->insert_record('message_read', $savemessage);
$message = $DB->get_record('message_read', array('id'=>$messageid));
phpunit_util::message_sent($message);
return $messageid;
}
}
// Fetch enabled processors
$processors = get_message_processors(true);
// Preset variables
$processorlist = array();
// Fill in the array of processors to be used based on default and user preferences
foreach ($processors as $processor) {
// Skip adding processors for internal user, if processor doesn't support sending message to internal user.
if (!$usertoisrealuser && !$processor->object->can_send_to_any_users()) {
continue;
}
// First find out permissions
$defaultpreference = $processor->name.'_provider_'.$preferencebase.'_permitted';
if (isset($defaultpreferences->{$defaultpreference})) {
$permitted = $defaultpreferences->{$defaultpreference};
} else {
// MDL-25114 They supplied an $eventdata->component $eventdata->name combination which doesn't
// exist in the message_provider table (thus there is no default settings for them).
$preferrormsg = "Could not load preference $defaultpreference. Make sure the component and name you supplied
to message_send() are valid.";
throw new coding_exception($preferrormsg);
}
示例2: test_message_redirection_reset
/**
* @depends test_message_redirection_noreset
*/
public function test_message_redirection_reset()
{
$this->assertFalse(phpunit_util::is_redirecting_messages(), 'Test reset must stop message redirection.');
}
示例3: message_send
//.........这里部分代码省略.........
}
if (!empty($eventdata->contexturl)) {
$savemessage->contexturl = $eventdata->contexturl;
} else {
$savemessage->contexturl = null;
}
if (!empty($eventdata->contexturlname)) {
$savemessage->contexturlname = $eventdata->contexturlname;
} else {
$savemessage->contexturlname = null;
}
$savemessage->timecreated = time();
if (PHPUNIT_TEST and class_exists('phpunit_util')) {
// Add some more tests to make sure the normal code can actually work.
$componentdir = get_component_directory($eventdata->component);
if (!$componentdir or !is_dir($componentdir)) {
throw new coding_exception('Invalid component specified in message-send(): '.$eventdata->component);
}
if (!file_exists("$componentdir/db/messages.php")) {
throw new coding_exception("$eventdata->component does not contain db/messages.php necessary for message_send()");
}
$messageproviders = null;
include("$componentdir/db/messages.php");
if (!isset($messageproviders[$eventdata->name])) {
throw new coding_exception("Missing messaging defaults for event '$eventdata->name' in '$eventdata->component' messages.php file");
}
unset($componentdir);
unset($messageproviders);
// Now ask phpunit if it wants to catch this message.
if (phpunit_util::is_redirecting_messages()) {
$savemessage->timeread = time();
$messageid = $DB->insert_record('message_read', $savemessage);
$message = $DB->get_record('message_read', array('id'=>$messageid));
phpunit_util::message_sent($message);
return $messageid;
}
}
// Fetch enabled processors
$processors = get_message_processors(true);
// Fetch default (site) preferences
$defaultpreferences = get_message_output_default_preferences();
// Preset variables
$processorlist = array();
$preferencebase = $eventdata->component.'_'.$eventdata->name;
// Fill in the array of processors to be used based on default and user preferences
foreach ($processors as $processor) {
// First find out permissions
$defaultpreference = $processor->name.'_provider_'.$preferencebase.'_permitted';
if (isset($defaultpreferences->{$defaultpreference})) {
$permitted = $defaultpreferences->{$defaultpreference};
} else {
//MDL-25114 They supplied an $eventdata->component $eventdata->name combination which doesn't
//exist in the message_provider table (thus there is no default settings for them)
$preferrormsg = get_string('couldnotfindpreference', 'message', $defaultpreference);
throw new coding_exception($preferrormsg,'blah');
}
// Find out if user has configured this output
// Some processors cannot function without settings from the user
$userisconfigured = $processor->object->is_user_configured($eventdata->userto);