From 322d3a6b6e60eb8f5809a2f2f45cd35ee74d5157 Mon Sep 17 00:00:00 2001 From: thangnn Date: Tue, 3 Dec 2024 21:01:35 +0700 Subject: [PATCH 1/2] Add unitTest_MailHelper_link --- .../bc-mail/src/View/Helper/MailHelper.php | 1 + .../TestCase/View/Helper/MailHelperTest.php | 22 +++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/plugins/bc-mail/src/View/Helper/MailHelper.php b/plugins/bc-mail/src/View/Helper/MailHelper.php index 3e91a8733d..74ab576b24 100755 --- a/plugins/bc-mail/src/View/Helper/MailHelper.php +++ b/plugins/bc-mail/src/View/Helper/MailHelper.php @@ -209,6 +209,7 @@ public function descriptionExists() * @return void * @checked * @noTodo + * @unitTest */ public function link($title, $contentsName, $datas = [], $options = []) { diff --git a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php index 49f7ff9eb7..b07804c494 100644 --- a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php +++ b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php @@ -158,23 +158,23 @@ public function testGetToken() */ public function testLink($title, $contentsName, $expected) { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + ContentFactory::make(['plugin' => 'BcMail', 'type' => 'MailContent', 'name' => $contentsName, 'entity_id' => 1])->persist(); $this->expectOutputString($expected); - $this->Mail->link($title, $contentsName, $datas = [], $options = []); + $this->MailHelper->link($title, $contentsName); } public static function linkProvider() { return [ - ['タイトル', 'Members', 'タイトル'], - [' ', 'a', ' '], - [' ', ' ', ' '], - [' ', '///', ' '], - [' ', '////a', ' '], - [' ', '////a//a/aa', ' '], - [' ', '/../../../../a', ' '], - ['', 'javascript:void(0);', ''], - ['', '////a', ''] + ['タイトル', 'Members', 'タイトル'], + [' ', 'a', ' '], + [' ', ' ', ' '], + [' ', '///', ' '], + [' ', '////a', ' '], + [' ', '////a//a/aa', ' '], + [' ', '/../../../../a', ' '], + ['', 'javascript:void(0);', ''], + ['', '////a', '<script>alert(1)</script>'] ]; } From e652709d6b04f6f310f1f7e2d47d6ec1b2abde0c Mon Sep 17 00:00:00 2001 From: thangnn Date: Tue, 10 Dec 2024 15:32:24 +0700 Subject: [PATCH 2/2] modified --- .../TestCase/View/Helper/MailHelperTest.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php index f97651d2f6..0779e58e28 100644 --- a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php +++ b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php @@ -149,9 +149,9 @@ public function testGetToken() * メールフォームへのリンクを取得 * @dataProvider linkProvider */ - public function testLink($title, $contentsName, $expected) + public function testLink($title, $contentsName, $url, $expected) { - ContentFactory::make(['plugin' => 'BcMail', 'type' => 'MailContent', 'name' => $contentsName, 'entity_id' => 1])->persist(); + ContentFactory::make(['plugin' => 'BcMail', 'type' => 'MailContent', 'name' => $contentsName, 'url' => $url, 'entity_id' => 1])->persist(); $this->expectOutputString($expected); $this->MailHelper->link($title, $contentsName); } @@ -159,15 +159,10 @@ public function testLink($title, $contentsName, $expected) public static function linkProvider() { return [ - ['タイトル', 'Members', 'タイトル'], - [' ', 'a', ' '], - [' ', ' ', ' '], - [' ', '///', ' '], - [' ', '////a', ' '], - [' ', '////a//a/aa', ' '], - [' ', '/../../../../a', ' '], - ['', 'javascript:void(0);', ''], - ['', '////a', '<script>alert(1)</script>'] + ['タイトル', '/Members/', '/a/', 'タイトル'], + [' ', 'a', '/a/', ' '], + [' ', ' ', '', ' '], + [' ', '///', '///', ' '], ]; }