本文整理汇总了PHP中phpunit_util::start_phpmailer_redirection方法的典型用法代码示例。如果您正苦于以下问题:PHP phpunit_util::start_phpmailer_redirection方法的具体用法?PHP phpunit_util::start_phpmailer_redirection怎么用?PHP phpunit_util::start_phpmailer_redirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpunit_util
的用法示例。
在下文中一共展示了phpunit_util::start_phpmailer_redirection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redirectEmails
/**
* Starts email redirection.
*
* You can verify if email were sent or not by inspecting the email
* array in the returned phpmailer sink instance. The redirection
* can be stopped by calling $sink->close();
*
* @return phpunit_message_sink
*/
public function redirectEmails() {
return phpunit_util::start_phpmailer_redirection();
}
示例2: reset_all_data
/**
* Reset contents of all database tables to initial values, reset caches, etc.
*
* Note: this is relatively slow (cca 2 seconds for pg and 7 for mysql) - please use with care!
*
* @static
* @param bool $detectchanges
* true - changes in global state and database are reported as errors
* false - no errors reported
* null - only critical problems are reported as errors
* @return void
*/
public static function reset_all_data($detectchanges = false)
{
global $DB, $CFG, $USER, $SITE, $COURSE, $PAGE, $OUTPUT, $SESSION;
// Stop any message redirection.
phpunit_util::stop_message_redirection();
// Stop any message redirection.
phpunit_util::stop_event_redirection();
// Start a new email redirection.
// This will clear any existing phpmailer redirection.
// We redirect all phpmailer output to this message sink which is
// called instead of phpmailer actually sending the message.
phpunit_util::start_phpmailer_redirection();
// We used to call gc_collect_cycles here to ensure desctructors were called between tests.
// This accounted for 25% of the total time running phpunit - so we removed it.
// Show any unhandled debugging messages, the runbare() could already reset it.
self::display_debugging_messages();
self::reset_debugging();
// reset global $DB in case somebody mocked it
$DB = self::get_global_backup('DB');
if ($DB->is_transaction_started()) {
// we can not reset inside transaction
$DB->force_transaction_rollback();
}
$resetdb = self::reset_database();
$warnings = array();
if ($detectchanges === true) {
if ($resetdb) {
$warnings[] = 'Warning: unexpected database modification, resetting DB state';
}
$oldcfg = self::get_global_backup('CFG');
$oldsite = self::get_global_backup('SITE');
foreach ($CFG as $k => $v) {
if (!property_exists($oldcfg, $k)) {
$warnings[] = 'Warning: unexpected new $CFG->' . $k . ' value';
} else {
if ($oldcfg->{$k} !== $CFG->{$k}) {
$warnings[] = 'Warning: unexpected change of $CFG->' . $k . ' value';
}
}
unset($oldcfg->{$k});
}
if ($oldcfg) {
foreach ($oldcfg as $k => $v) {
$warnings[] = 'Warning: unexpected removal of $CFG->' . $k;
}
}
if ($USER->id != 0) {
$warnings[] = 'Warning: unexpected change of $USER';
}
if ($COURSE->id != $oldsite->id) {
$warnings[] = 'Warning: unexpected change of $COURSE';
}
if ($CFG->ostype === 'WINDOWS') {
if (setlocale(LC_TIME, 0) !== 'English_Australia.1252') {
$warnings[] = 'Warning: unexpected change of locale';
}
} else {
if (setlocale(LC_TIME, 0) !== 'en_AU.UTF-8') {
$warnings[] = 'Warning: unexpected change of locale';
}
}
}
if (ini_get('max_execution_time') != 0) {
// This is special warning for all resets because we do not want any
// libraries to mess with timeouts unintentionally.
// Our PHPUnit integration is not supposed to change it either.
if ($detectchanges !== false) {
$warnings[] = 'Warning: max_execution_time was changed to ' . ini_get('max_execution_time');
}
set_time_limit(0);
}
// restore original globals
$_SERVER = self::get_global_backup('_SERVER');
$CFG = self::get_global_backup('CFG');
$SITE = self::get_global_backup('SITE');
$_GET = array();
$_POST = array();
$_FILES = array();
$_REQUEST = array();
$COURSE = $SITE;
// reinitialise following globals
$OUTPUT = new bootstrap_renderer();
$PAGE = new moodle_page();
$FULLME = null;
$ME = null;
$SCRIPT = null;
// Empty sessison and set fresh new not-logged-in user.
\core\session\manager::init_empty_session();
//.........这里部分代码省略.........