diff --git a/plugins/bc-mail/src/View/Helper/MailHelper.php b/plugins/bc-mail/src/View/Helper/MailHelper.php index ddab526f16..1eaa131889 100755 --- a/plugins/bc-mail/src/View/Helper/MailHelper.php +++ b/plugins/bc-mail/src/View/Helper/MailHelper.php @@ -244,6 +244,7 @@ public function link($title, $contentsName, $datas = [], $options = []) * @return string * @checked * @noTodo + * @unitTest */ public function getToken() { @@ -256,6 +257,7 @@ public function getToken() * @return void * @checked * @noTodo + * @unitTest */ public function token() { @@ -338,6 +340,7 @@ public function isMail(): bool * @return mixed * @checked * @noTodo + * @unitTest */ public function getPublishedMailContents(int $siteId) { diff --git a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php index fb144e7c27..6815294849 100644 --- a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php +++ b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php @@ -14,24 +14,32 @@ use BaserCore\TestSuite\BcTestCase; use BaserCore\View\BcFrontAppView; use BcMail\Model\Entity\MailContent; +use BcMail\Test\Scenario\MailContentsScenario; use BcMail\View\Helper\MailHelper; use Cake\ORM\Entity; -use Cake\View\View; +use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; /** * Class MailHelperTest * - * @property MailHelper $Mail + * @property MailHelper $MailHelper */ class MailHelperTest extends BcTestCase { + /** + * ScenarioAwareTrait + */ + use ScenarioAwareTrait; + /** * set up */ 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); } /** @@ -39,7 +47,7 @@ public function setUp(): void */ public function tearDown(): void { -// unset($this->Mail); + unset($this->MailHelper); parent::tearDown(); } @@ -114,9 +122,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); } @@ -126,9 +131,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); } @@ -138,10 +140,9 @@ public function testGetMailTemplates() */ public function testGetToken() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); - $result = $this->Mail->getToken(); + $result = $this->MailHelper->getToken(); $expected = '/.*/s'; - $this->assertMatchesRegularExpression($expected, $result, 'スクリプトが取得できません。'); + $this->assertMatchesRegularExpression($expected, $result); } /** @@ -255,4 +256,14 @@ public function test_isMail() $result = $this->MailHelper->isMail(); $this->assertTrue($result); } + + /** + * test getPublishedMailContents + */ + public function testGetPublishedMailContents() + { + $this->loadFixtureScenario(MailContentsScenario::class); + $rs = $this->MailHelper->getPublishedMailContents(1); + $this->assertEquals(1, $rs->count()); + } }