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'])) { 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') diff --git a/plugins/bc-mail/src/View/Helper/MailHelper.php b/plugins/bc-mail/src/View/Helper/MailHelper.php index 74ab576b24..4d3894322f 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) { @@ -244,6 +245,7 @@ public function link($title, $contentsName, $datas = [], $options = []) * @return string * @checked * @noTodo + * @unitTest */ public function getToken() { @@ -256,6 +258,7 @@ public function getToken() * @return void * @checked * @noTodo + * @unitTest */ public function token() { @@ -338,6 +341,7 @@ public function isMail(): bool * @return mixed * @checked * @noTodo + * @unitTest */ public function getPublishedMailContents(int $siteId) { 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/MailHelperTest.php b/plugins/bc-mail/tests/TestCase/View/Helper/MailHelperTest.php index b07804c494..f97651d2f6 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,19 +131,8 @@ 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, 'メールテンプレートの取得結果が違います。'); + $result = $this->MailHelper->getMailTemplates(1); + $this->assertEquals(['mail_default' => 'mail_default'], $result); } /** @@ -146,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); } /** @@ -263,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()); + } } 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'] ]; } }