Skip to content

Commit

Permalink
Merge pull request #4049 from thangnnmd/unitTest_MailMessageMailer_se…
Browse files Browse the repository at this point in the history
…ndFormToUser

MailMessageMailer::sendFormToUser
  • Loading branch information
HungDV2022 authored Nov 28, 2024
2 parents 6df4958 + 101da5c commit b237705
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugins/bc-mail/src/Mailer/MailMessageMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function sendFormToAdmin(
* @param array $options
* @checked
* @noTodo
* @unitTest
*/
public function sendFormToUser(
EntityInterface $mailContent,
Expand Down
28 changes: 27 additions & 1 deletion plugins/bc-mail/tests/TestCase/Mailer/MailMessageMailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,33 @@ public function testSendFormToAdmin()
*/
public function testSendFormToUser()
{
$this->markTestIncomplete('このテストは未実装');
//準備
$data['message'] = 'message test';
$data['mailContent'] = 'content test';
$data['mailFields'] = 'fields test';
$mailContent = MailContentFactory::make([
'description' => 'description test',
'sender_1' => 'sender_1',
'sender_name' => 'name 111',
'subject_user' => 'subject_user 111',
'subject_admin' => 'subject_admin 111',
'form_template' => 'default',
'mail_template' => 'mail_default',
'redirect_url' => '/',
])->getEntity();

//テスト
$this->MailMessageMailer->sendFormToUser($mailContent, '[email protected]', '[email protected]', $data, [], []);

//戻り値を確認
$this->assertEquals(['[email protected]' => '[email protected]'], $this->MailMessageMailer->getReplyTo());
$this->assertEquals(['[email protected]' => '[email protected]'], $this->MailMessageMailer->getTo());

$vars = $this->MailMessageMailer->viewBuilder()->getVars();
$this->assertEquals('message test', $vars['message']);
$this->assertEquals('content test', $vars['mailContent']);
$this->assertEquals('fields test', $vars['mailFields']);
$this->assertEquals('user', $vars['other']['mode']);
}

/**
Expand Down

0 comments on commit b237705

Please sign in to comment.