-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4048 from thangnnmd/unitTest_MailMessageMailer_se…
…ndFormToAdmin MailMessageMailer::sendFormToAdmin
- Loading branch information
Showing
2 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
plugins/bc-mail/tests/TestCase/Mailer/MailMessageMailerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
/** | ||
* baserCMS : Based Website Development Project <https://basercms.net> | ||
* Copyright (c) NPO baser foundation <https://baserfoundation.org/> | ||
* | ||
* @copyright Copyright (c) NPO baser foundation | ||
* @link https://basercms.net baserCMS Project | ||
* @since 5.0.0 | ||
* @license https://basercms.net/license/index.html MIT License | ||
*/ | ||
|
||
namespace BcMail\Test\TestCase\Mailer; | ||
|
||
use BaserCore\Test\Factory\SiteConfigFactory; | ||
use BaserCore\TestSuite\BcTestCase; | ||
use BcMail\Mailer\MailMessageMailer; | ||
use BcMail\Test\Factory\MailContentFactory; | ||
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; | ||
|
||
/** | ||
* MailMessageMailerTest | ||
* | ||
* @property MailMessageMailer $MailMessageMailer | ||
*/ | ||
class MailMessageMailerTest extends BcTestCase | ||
{ | ||
|
||
/** | ||
* ScenarioAwareTrait | ||
*/ | ||
use ScenarioAwareTrait; | ||
|
||
/** | ||
* set up | ||
*/ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
SiteConfigFactory::make(['name' => 'email', 'value' => '[email protected]'])->persist(); | ||
$this->MailMessageMailer = new MailMessageMailer(); | ||
} | ||
|
||
/** | ||
* tear down | ||
*/ | ||
public function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* test sendFormToAdmin | ||
*/ | ||
public function testSendFormToAdmin() | ||
{ | ||
//準備 | ||
$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->sendFormToAdmin($mailContent, '[email protected]', '[email protected]', $data, [], []); | ||
|
||
//戻り値を確認 | ||
$this->assertEquals(['[email protected]' => '[email protected]'], $this->MailMessageMailer->getTo()); | ||
$this->assertEquals(['[email protected]' => '[email protected]'], $this->MailMessageMailer->getReplyTo()); | ||
|
||
$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('admin', $vars['other']['mode']); | ||
} | ||
|
||
/** | ||
* test sendFormToUser | ||
*/ | ||
public function testSendFormToUser() | ||
{ | ||
$this->markTestIncomplete('このテストは未実装'); | ||
} | ||
|
||
/** | ||
* test getFrom | ||
*/ | ||
public function testGetFrom() | ||
{ | ||
$this->markTestIncomplete('このテストは未実装'); | ||
} | ||
} |