From 00d4f47bf48d331505856c82564c328d42abab1d Mon Sep 17 00:00:00 2001 From: HungDV2022 Date: Tue, 3 Dec 2024 11:38:14 +0900 Subject: [PATCH 1/8] =?UTF-8?q?MailHelper::getMailTemplates=E3=83=A6?= =?UTF-8?q?=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 | 19 ++++++------------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/plugins/bc-mail/src/View/Helper/MailHelper.php b/plugins/bc-mail/src/View/Helper/MailHelper.php index 3e91a8733d..ddab526f16 100755 --- a/plugins/bc-mail/src/View/Helper/MailHelper.php +++ b/plugins/bc-mail/src/View/Helper/MailHelper.php @@ -127,6 +127,7 @@ public function getFormTemplates($siteId = 1) * @todo 他のヘルパに移動する * @checked * @noTodo + * @unitTest */ public function getMailTemplates($siteId = 1) { diff --git a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php index 49f7ff9eb7..e173b1a65a 100644 --- a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php +++ b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php @@ -15,6 +15,7 @@ use BaserCore\View\BcFrontAppView; use BcMail\Model\Entity\MailContent; use BcMail\View\Helper\MailHelper; +use Cake\Core\Configure; use Cake\ORM\Entity; use Cake\View\View; @@ -126,19 +127,11 @@ public function testGetFormTemplates() */ public function testGetMailTemplates() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); - $View = new View(null); - $View->set('siteConfig', Configure::read('BcSite')); - $this->Mail->BcBaser = new BcBaserHelper($View); - $result = $this->Mail->getMailTemplates(); - $expected = [ - 'mail_default' => 'mail_default', - 'default' => 'default', - 'reset_password' => 'reset_password', - 'send_activate_url' => 'send_activate_url', - 'send_activate_urls' => 'send_activate_urls', - ]; - $this->assertEquals($result, $expected, 'メールテンプレートの取得結果が違います。'); + 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); } /** From 782e5aa4913c951661ad2f5c67ba3633647efef8 Mon Sep 17 00:00:00 2001 From: HungDV2022 Date: Tue, 3 Dec 2024 11:40:53 +0900 Subject: [PATCH 2/8] =?UTF-8?q?MailHelper::getMailTemplates=E3=83=A6?= =?UTF-8?q?=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 --- plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php index e173b1a65a..fb144e7c27 100644 --- a/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php +++ b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php @@ -15,7 +15,6 @@ use BaserCore\View\BcFrontAppView; use BcMail\Model\Entity\MailContent; use BcMail\View\Helper\MailHelper; -use Cake\Core\Configure; use Cake\ORM\Entity; use Cake\View\View; From 23d9b7eccf7eccc2c05418a3398054235af299d9 Mon Sep 17 00:00:00 2001 From: maenoasuka <159506469+maenoasuka@users.noreply.github.com> Date: Wed, 4 Dec 2024 07:31:15 +0900 Subject: [PATCH 3/8] =?UTF-8?q?addAdminMainBodyHeaderLinks()=E3=81=A7?= =?UTF-8?q?=E5=A4=96=E9=83=A8=E3=83=AA=E3=83=B3=E3=82=AF=E3=82=92=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20fix=20#4030=20(#4059)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/Admin/element/main_body_header_links.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bc-admin-third/templates/Admin/element/main_body_header_links.php b/plugins/bc-admin-third/templates/Admin/element/main_body_header_links.php index 3c5bbee28b..d08d216914 100644 --- a/plugins/bc-admin-third/templates/Admin/element/main_body_header_links.php +++ b/plugins/bc-admin-third/templates/Admin/element/main_body_header_links.php @@ -35,7 +35,7 @@ if (empty($link['class'])) { $link['class'] = 'bca-btn'; } - if (empty($link['data-bca-btn-type'])) { + if (empty($link['data-bca-btn-type']) && !empty($url['action'])) { $link['data-bca-btn-type'] = $url['action']; } if (empty($link['data-bca-btn-size'])) { From 4c045aa09b29bf28637ef58df654d20d16498d76 Mon Sep 17 00:00:00 2001 From: maenoasuka <159506469+maenoasuka@users.noreply.github.com> Date: Wed, 4 Dec 2024 07:32:39 +0900 Subject: [PATCH 4/8] =?UTF-8?q?=E3=83=A1=E3=83=BC=E3=83=AB=E3=83=95?= =?UTF-8?q?=E3=82=A9=E3=83=BC=E3=83=A0=E5=8F=97=E4=BB=98=E6=9C=9F=E9=96=93?= =?UTF-8?q?=E3=81=AEpublish=5Fend=E3=81=AB=E3=83=90=E3=83=AA=E3=83=87?= =?UTF-8?q?=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E8=BF=BD=E5=8A=A0=20fix=20?= =?UTF-8?q?#4000=20(#4060)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Model/Table/MailContentsTable.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/bc-mail/src/Model/Table/MailContentsTable.php b/plugins/bc-mail/src/Model/Table/MailContentsTable.php index 8dfb09590e..854f16bb40 100755 --- a/plugins/bc-mail/src/Model/Table/MailContentsTable.php +++ b/plugins/bc-mail/src/Model/Table/MailContentsTable.php @@ -157,6 +157,23 @@ public function validationDefault(Validator $validator): Validator ] ]); + // publish_end + $validator + ->add('publish_end', [ + 'dateTime' => [ + 'rule' => ['dateTime'], + 'message' => __d('baser_core', '公開終了日に不正な文字列が入っています。') + ] + ]) + ->allowEmptyDateTime('publish_end') + ->add('publish_end', [ + 'checkDateAfterThan' => [ + 'rule' => ['checkDateAfterThan', 'publish_begin'], + 'provider' => 'bc', + 'message' => __d('baser_core', '公開終了日は、公開開始日より新しい日付で入力してください。') + ] + ]); + // sender_1 $validator ->scalar('sender_1') From d90f2ea20a3fd944f9a22efebb38186b2970f737 Mon Sep 17 00:00:00 2001 From: HungDV2022 Date: Wed, 4 Dec 2024 09:12:42 +0900 Subject: [PATCH 5/8] =?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 6/8] =?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 7/8] =?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()); + } } From 0d71ec098e2b05444f44fef0f12f582fd0b2b53e Mon Sep 17 00:00:00 2001 From: thangnn Date: Wed, 4 Dec 2024 14:19:47 +0700 Subject: [PATCH 8/8] Add unitTest_MaildataHelper_toDisplayString --- .../src/View/Helper/MaildataHelper.php | 3 +- .../View/Helper/MaildataHelperTest.php | 88 ++++++++++++------- 2 files changed, 58 insertions(+), 33 deletions(-) diff --git a/plugins/bc-mail/src/View/Helper/MaildataHelper.php b/plugins/bc-mail/src/View/Helper/MaildataHelper.php index 455f511abb..26ca8a1a2c 100755 --- a/plugins/bc-mail/src/View/Helper/MaildataHelper.php +++ b/plugins/bc-mail/src/View/Helper/MaildataHelper.php @@ -64,6 +64,7 @@ public function control($type, $value, $escape = true) * @return string メール用データ * @checked * @noTodo + * @unitTest */ public function toDisplayString(string $type, $value, bool $prefixSpace = true) { @@ -77,7 +78,7 @@ public function toDisplayString(string $type, $value, bool $prefixSpace = true) case 'number': case 'password': $result = $value; - + break; case 'pref': $prefs = $this->prefList(); $options = []; diff --git a/plugins/bc-mail/tests/TestCase/View/Helper/MaildataHelperTest.php b/plugins/bc-mail/tests/TestCase/View/Helper/MaildataHelperTest.php index 61c430213a..48e1cafb32 100644 --- a/plugins/bc-mail/tests/TestCase/View/Helper/MaildataHelperTest.php +++ b/plugins/bc-mail/tests/TestCase/View/Helper/MaildataHelperTest.php @@ -1,29 +1,34 @@ MaildataHelper = new MaildataHelper(new View()); + $view = new BcFrontAppView($this->getRequest('/')); + $this->MaildataHelper = new MaildataHelper($view); } /** * tear down */ - public function tearDown():void + public function tearDown(): void { unset($this->MaildataHelper); parent::tearDown(); } + /** * メール表示用のデータを出力する * @dataProvider controlDataProvider @@ -37,8 +42,8 @@ public function testControl($type, $value, $escape, $expected) public static function controlDataProvider() { return [ - ['text' , 'bold', true, ' <b>bold</b>'], - ['text' , 'bold', false, ' bold'], + ['text', 'bold', true, ' <b>bold</b>'], + ['text', 'bold', false, ' bold'], ]; } @@ -48,12 +53,7 @@ public static function controlDataProvider() */ public function testToDisplayString($type, $value, $options, $expected) { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); - if ($type == 'file') { - $this->View->set('mailContent', ['MailContent' => ['id' => 1]]); - } - - $result = $this->Maildata->toDisplayString($type, $value, $options); + $result = $this->MaildataHelper->toDisplayString($type, $value, $options); $this->assertEquals($result, $expected); } @@ -75,33 +75,57 @@ public static function toDisplayStringProvider() ['email', 'hoge', '', 'hoge'], ['hidden', 'hoge', '', 'hoge'], ['radio', '', '', ''], - ['radio', '', $options, ''], - ['radio', 'hoge', $options, 'hoge'], - ['radio', 'h', $options, 'h'], + ['radio', $options, '', '・資料請求 +・お問い合わせ +・その他 +'], + ['radio', $options, true, ' ・資料請求 + ・お問い合わせ + ・その他 +'], + ['radio', $options, false, '・資料請求 +・お問い合わせ +・その他 +'], ['select', '', '', ''], - ['select', '', $options, ''], - ['select', 'hoge', $options, 'hoge'], - ['select', 'h', $options, 'h'], + ['select', $options, '', '・資料請求 +・お問い合わせ +・その他 +'], + ['select', $options, '', '・資料請求 +・お問い合わせ +・その他 +'], ['pref', '', '', ''], ['pref', '東京都', '', '東京都'], ['pref', '福岡県', '', '福岡県'], ['check', '', '', ''], - ['check', '', $options, ''], + ['check', $options, '', '・資料請求 +・お問い合わせ +・その他 +'], ['check', 'hoge', '', 'hoge'], - ['check', 'hoge', $options, 'hoge'], + ['check', $options, '', '・資料請求 +・お問い合わせ +・その他 +'], ['multi_check', '', '', ''], - ['multi_check', '', $options, ''], - ['multi_check', $get, $options, "・hoge\n ・hello\n ・world\n"], - ['file', 'hoge', $options, 'hoge'], - ['file', 'test/hoge.jpg', $options, ''], - //TODO 西暦のオーバーフロー処理ができてない - ['date_time_calender', 'hoge', $options, '1970年 01月 01日'], - ['date_time_calender', '21000828', $options, '2100年 08月 28日'], - ['date_time_calender', '2100/08/32', $options, '1970年 01月 01日'], - ['date_time_calender', '', $options, ''], - ['autozip', '888-0000', $options, '888-0000'], - ['autozip', '8880000', $options, '888-0000'], - ['', 'hoge', $options, 'hoge'] + ['multi_check', $options, '', '・資料請求 +・お問い合わせ +・その他 +'], + ['multi_check', $get, '', "・hoge +・hello +・world +"], +// ['file', 'hoge', '', 'hoge'], + ['date_time_calender', 'hoge', '', '1970年 01月 01日'], + ['date_time_calender', '21000828', '', '2100年 08月 28日'], + ['date_time_calender', '2100/08/32', '', '1970年 01月 01日'], + ['date_time_calender', '', '', ''], + ['autozip', '888-0000', '', '888-0000'], + ['autozip', '8880000', '', '888-0000'], + ['', 'hoge', '', 'hoge'] ]; } }