Skip to content

Commit

Permalink
Merge pull request #4062 from HungDV2022/unittest_MailHelper_getToken
Browse files Browse the repository at this point in the history
MailHelper::getToken() ユニットテスト
  • Loading branch information
HungDV2022 authored Dec 5, 2024
2 parents 0015233 + f843fb7 commit 5d4c410
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
2 changes: 2 additions & 0 deletions plugins/bc-mail/src/View/Helper/MailHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public function link($title, $contentsName, $datas = [], $options = [])
* @return string
* @checked
* @noTodo
* @unitTest
*/
public function getToken()
{
Expand All @@ -256,6 +257,7 @@ public function getToken()
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function token()
{
Expand Down
17 changes: 6 additions & 11 deletions plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Class MailHelperTest
*
* @property MailHelper $Mail
* @property MailHelper $MailHelper
*/
class MailHelperTest extends BcTestCase
{
Expand All @@ -31,7 +31,9 @@ class MailHelperTest extends BcTestCase
public function setUp(): void
{
parent::setUp();
$this->MailHelper = new MailHelper(new View());
SiteFactory::make(['id' => '1'])->persist();
$view = new BcFrontAppView($this->getRequest('/'));
$this->MailHelper = new MailHelper($view);
}

/**
Expand Down Expand Up @@ -114,9 +116,6 @@ public function testGetForm()
*/
public function testGetFormTemplates()
{
SiteFactory::make(['id' => '1'])->persist();
$view = new BcFrontAppView($this->getRequest('/'));
$this->MailHelper = new MailHelper($view);
$result = $this->MailHelper->getFormTemplates(1);
$this->assertEquals(['default' => 'default'], $result);
}
Expand All @@ -126,9 +125,6 @@ public function testGetFormTemplates()
*/
public function testGetMailTemplates()
{
SiteFactory::make(['id' => '1'])->persist();
$view = new BcFrontAppView($this->getRequest('/'));
$this->MailHelper = new MailHelper($view);
$result = $this->MailHelper->getMailTemplates(1);
$this->assertEquals(['mail_default' => 'mail_default'], $result);
}
Expand All @@ -138,10 +134,9 @@ public function testGetMailTemplates()
*/
public function testGetToken()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
$result = $this->Mail->getToken();
$result = $this->MailHelper->getToken();
$expected = '/<script.*<\/script>.*/s';
$this->assertMatchesRegularExpression($expected, $result, 'スクリプトが取得できません。');
$this->assertMatchesRegularExpression($expected, $result);
}

/**
Expand Down

0 comments on commit 5d4c410

Please sign in to comment.