Skip to content

Commit

Permalink
Add unitTest_MailMessageMailer_sendFormToUser
Browse files Browse the repository at this point in the history
  • Loading branch information
thangnn committed Nov 27, 2024
1 parent d823fd5 commit 101da5c
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 101da5c

Please sign in to comment.