Skip to content

Commit

Permalink
MailHelper::getToken() ユニットテスト
Browse files Browse the repository at this point in the history
  • Loading branch information
dovanhung committed Dec 4, 2024
1 parent 0015233 commit d90f2ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
1 change: 1 addition & 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 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 d90f2ea

Please sign in to comment.