From d90f2ea20a3fd944f9a22efebb38186b2970f737 Mon Sep 17 00:00:00 2001 From: HungDV2022 Date: Wed, 4 Dec 2024 09:12:42 +0900 Subject: [PATCH 1/3] =?UTF-8?q?MailHelper::getToken()=20=E3=83=A6=E3=83=8B?= =?UTF-8?q?=E3=83=83=E3=83=88=E3=83=86=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/bc-mail/src/View/Helper/MailHelper.php | 1 + .../TestCase/View/Helper/MailHelperTest.php | 17 ++++++----------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/plugins/bc-mail/src/View/Helper/MailHelper.php b/plugins/bc-mail/src/View/Helper/MailHelper.php index ddab526f16..d0e86a05dd 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() { diff --git a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php index fb144e7c27..e803823d12 100644 --- a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php +++ b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php @@ -21,7 +21,7 @@ /** * Class MailHelperTest * - * @property MailHelper $Mail + * @property MailHelper $MailHelper */ class MailHelperTest extends BcTestCase { @@ -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); } /** @@ -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); } @@ -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); } @@ -138,10 +134,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); } /** From f843fb7d7cd8268a860fb0020ab9630f803a6815 Mon Sep 17 00:00:00 2001 From: HungDV2022 Date: Wed, 4 Dec 2024 09:13:42 +0900 Subject: [PATCH 2/3] =?UTF-8?q?MailHelper::getToken()=20=E3=83=A6=E3=83=8B?= =?UTF-8?q?=E3=83=83=E3=83=88=E3=83=86=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/bc-mail/src/View/Helper/MailHelper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/bc-mail/src/View/Helper/MailHelper.php b/plugins/bc-mail/src/View/Helper/MailHelper.php index d0e86a05dd..7063c5468d 100755 --- a/plugins/bc-mail/src/View/Helper/MailHelper.php +++ b/plugins/bc-mail/src/View/Helper/MailHelper.php @@ -257,6 +257,7 @@ public function getToken() * @return void * @checked * @noTodo + * @unitTest */ public function token() { From 91273bc0eced4d8c0f7c26991510a0eaf513e9a2 Mon Sep 17 00:00:00 2001 From: HungDV2022 Date: Wed, 4 Dec 2024 09:19:55 +0900 Subject: [PATCH 3/3] =?UTF-8?q?MailHelper::getPublishedMailContents()=20?= =?UTF-8?q?=E3=83=A6=E3=83=8B=E3=83=83=E3=83=88=E3=83=86=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bc-mail/src/View/Helper/MailHelper.php | 1 + .../TestCase/View/Helper/MailHelperTest.php | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/plugins/bc-mail/src/View/Helper/MailHelper.php b/plugins/bc-mail/src/View/Helper/MailHelper.php index 7063c5468d..1eaa131889 100755 --- a/plugins/bc-mail/src/View/Helper/MailHelper.php +++ b/plugins/bc-mail/src/View/Helper/MailHelper.php @@ -340,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 e803823d12..6815294849 100644 --- a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php +++ b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php @@ -14,9 +14,10 @@ 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 @@ -25,6 +26,11 @@ */ class MailHelperTest extends BcTestCase { + /** + * ScenarioAwareTrait + */ + use ScenarioAwareTrait; + /** * set up */ @@ -41,7 +47,7 @@ public function setUp(): void */ public function tearDown(): void { -// unset($this->Mail); + unset($this->MailHelper); parent::tearDown(); } @@ -250,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()); + } }