当前位置: 首页>>代码示例>>PHP>>正文


PHP phpunit_util::is_redirecting_phpmailer方法代码示例

本文整理汇总了PHP中phpunit_util::is_redirecting_phpmailer方法的典型用法代码示例。如果您正苦于以下问题:PHP phpunit_util::is_redirecting_phpmailer方法的具体用法?PHP phpunit_util::is_redirecting_phpmailer怎么用?PHP phpunit_util::is_redirecting_phpmailer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpunit_util的用法示例。


在下文中一共展示了phpunit_util::is_redirecting_phpmailer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PostSend

 protected function PostSend()
 {
     // Now ask phpunit if it wants to catch this message.
     if (PHPUNIT_TEST) {
         if (!phpunit_util::is_redirecting_phpmailer()) {
             debugging('Unit tests must not send real emails! Use $this->start_phpmailer_redirection()');
             return true;
         }
         $mail = new stdClass();
         $mail->header = $this->MIMEHeader;
         $mail->body = $this->MIMEBody;
         $mail->subject = $this->Subject;
         $mail->from = $this->From;
         $mail->to = $this->to[0][0];
         phpunit_util::phpmailer_sent($mail);
         return true;
     } else {
         return parent::PostSend();
     }
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:20,代码来源:moodle_phpmailer.php

示例2: test_message_attachment_send

 public function test_message_attachment_send()
 {
     global $CFG;
     $this->preventResetByRollback();
     $this->resetAfterTest();
     // Set config setting to allow attachments.
     $CFG->allowattachments = true;
     unset_config('noemailever');
     $user = $this->getDataGenerator()->create_user();
     $context = context_user::instance($user->id);
     // Create a test file.
     $fs = get_file_storage();
     $filerecord = array('contextid' => $context->id, 'component' => 'core', 'filearea' => 'unittest', 'itemid' => 99999, 'filepath' => '/', 'filename' => 'emailtest.txt');
     $file = $fs->create_file_from_string($filerecord, 'Test content');
     $message = new stdClass();
     $message->component = 'moodle';
     $message->name = 'instantmessage';
     $message->userfrom = get_admin();
     $message->userto = $user;
     $message->subject = 'message subject 1';
     $message->fullmessage = 'message body';
     $message->fullmessageformat = FORMAT_MARKDOWN;
     $message->fullmessagehtml = '<p>message body</p>';
     $message->smallmessage = 'small message';
     $message->attachment = $file;
     $message->attachname = 'emailtest.txt';
     $message->notification = 0;
     // Make sure we are redirecting emails.
     $sink = $this->redirectEmails();
     $this->assertTrue(phpunit_util::is_redirecting_phpmailer());
     message_send($message);
     // Get the email that we just sent.
     $emails = $sink->get_messages();
     $email = reset($emails);
     $this->assertTrue(strpos($email->body, 'Content-Disposition: attachment;') !== false);
     $this->assertTrue(strpos($email->body, 'emailtest.txt') !== false);
     // Check if the stored file still exists after remove the temporary attachment.
     $storedfileexists = $fs->file_exists($filerecord['contextid'], $filerecord['component'], $filerecord['filearea'], $filerecord['itemid'], $filerecord['filepath'], $filerecord['filename']);
     $this->assertTrue($storedfileexists);
 }
开发者ID:LepilkinaElena,项目名称:moodle,代码行数:40,代码来源:messagelib_test.php


注:本文中的phpunit_util::is_redirecting_phpmailer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。