test(email): 更新了邮件发送的测试账号

This commit is contained in:
李东云
2023-02-27 11:05:13 +08:00
parent a7a8087509
commit 8dcf586baf
2 changed files with 22 additions and 14 deletions

View File

@@ -57,7 +57,11 @@
"hyperf/session": "Session 鉴权必需", "hyperf/session": "Session 鉴权必需",
"symfony/mailer": "用于发送电子邮件", "symfony/mailer": "用于发送电子邮件",
"guzzlehttp/guzzle": "需要发起 http 请求时必需", "guzzlehttp/guzzle": "需要发起 http 请求时必需",
"alibabacloud/dysmsapi-20170525": "阿里云短信服务必需" "alibabacloud/dysmsapi-20170525": "阿里云短信服务必需",
"laminas/laminas-text": "用于cli展示表格和大字",
"gevman/interactive-cli": "用于提供漂亮的交互式命令行",
"clue/stdio-react": "一个基于 reactphp 的交互式命令行",
"brainmaestro/composer-git-hooks": "用于 php 项目的 git-hooks"
}, },
"config": { "config": {
"optimize-autoloader": true, "optimize-autoloader": true,

View File

@@ -12,25 +12,27 @@ namespace Singularity\HDK\Test\Core\Service;
use Singularity\HDK\Core\Service\EmailService; use Singularity\HDK\Core\Service\EmailService;
use Symfony\Component\Mailer\Exception\TransportException; use Symfony\Component\Mailer\Exception\TransportException;
$dsn = 'smtp://account@luxcreo.ai:Qfsd8866@smtp.qiye.aliyun.com:465'; $dsn = 'smtp://account@luxcreo.com:Qfsd8866@smtp-mail.outlook.com:587';
$mail_sender_name = 'LuxCreo'; $mail_sender_name = 'LuxCreo';
$mail_sender = 'account@luxcreo.ai'; $mail_sender = 'account@luxcreo.com';
$email = new EmailService($dsn, $mail_sender_name, $mail_sender); $email = new EmailService($dsn, $mail_sender_name, $mail_sender);
it('assertions that send HTML is available', function () use ($email) { $target = 'dongyun.li@luxcreo.ai';
$result = $email->sendHtml(
'dongyun.li@luxcreo.ai', it('assertions that send HTML is available', function () use ($email, $target) {
'HDK Unit Test HTML', $result = $email->sendHtml(
<<<HTML $target,
'HDK Unit Test HTML',
<<<HTML
<h1>Hello, World!</h1> <h1>Hello, World!</h1>
HTML HTML
); );
expect($result)->toBeTrue(); expect($result)->toBeTrue();
}); });
it('assertions that send Text is available', function () use ($email) { it('assertions that send Text is available', function () use ($email, $target) {
$result = $email->sendText( $result = $email->sendText(
'dongyun.li@luxcreo.ai', $target,
'HDK Unit Test Text', 'HDK Unit Test Text',
<<<Text <<<Text
<h1>Hello, World!</h1> <h1>Hello, World!</h1>
@@ -41,24 +43,26 @@ Text
it('assertions Error Receiver can be catch', function () use ($email) { it('assertions Error Receiver can be catch', function () use ($email) {
try { try {
$email->sendHtml( $result = $email->sendHtml(
'unknown@luxcreo.ai', 'unknown@luxcreo.ai',
'HDK Unit Test', 'HDK Unit Test',
<<<HTML <<<HTML
<h1>Hello, World!</h1> <h1>Hello, World!</h1>
HTML HTML
); );
expect($result)->toBeTrue();
} catch (TransportException $t) { } catch (TransportException $t) {
expect($t->getCode())->toBe(554); expect($t->getCode())->toBe(554);
} }
try { try {
$email->sendText( $result = $email->sendText(
'unknown@luxcreo.ai', 'unknown@luxcreo.ai',
'HDK Unit Test', 'HDK Unit Test',
<<<Text <<<Text
<h1>Hello, World!</h1> <h1>Hello, World!</h1>
Text Text
); );
expect($result)->toBeTrue();
} catch (TransportException $t) { } catch (TransportException $t) {
expect($t->getCode())->toBe(554); expect($t->getCode())->toBe(554);
} }