From 0f957ccdb57cbe623b0461a27ad5dc425e8439e2 Mon Sep 17 00:00:00 2001 From: HungDV2022 Date: Wed, 11 Dec 2024 10:37:29 +0900 Subject: [PATCH 1/2] =?UTF-8?q?MailformHelper::authCaptcha()=20=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 --- .../plugin/BcMail/element/auth_captcha.php | 2 +- .../src/View/Helper/MailformHelper.php | 1 + .../View/Helper/MailformHelperTest.php | 29 ++++++++++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/plugins/bc-front/templates/plugin/BcMail/element/auth_captcha.php b/plugins/bc-front/templates/plugin/BcMail/element/auth_captcha.php index c3f498d710..8b2fe10228 100644 --- a/plugins/bc-front/templates/plugin/BcMail/element/auth_captcha.php +++ b/plugins/bc-front/templates/plugin/BcMail/element/auth_captcha.php @@ -24,7 +24,7 @@ ?> - +
BcBaser->img($captchaUrl, ['alt' => __d('baser_core', '認証画像'), 'class' => $options['class']]) ?> diff --git a/plugins/bc-mail/src/View/Helper/MailformHelper.php b/plugins/bc-mail/src/View/Helper/MailformHelper.php index 45b04a688e..d6530ed63a 100755 --- a/plugins/bc-mail/src/View/Helper/MailformHelper.php +++ b/plugins/bc-mail/src/View/Helper/MailformHelper.php @@ -275,6 +275,7 @@ public function create($context = null, $options = []): string * @return void * @checked * @noTodo + * @unitTest */ public function authCaptcha(string $fieldName, array $options = []) { diff --git a/plugins/bc-mail/tests/TestCase/View/Helper/MailformHelperTest.php b/plugins/bc-mail/tests/TestCase/View/Helper/MailformHelperTest.php index 285332f5e9..39692e659c 100644 --- a/plugins/bc-mail/tests/TestCase/View/Helper/MailformHelperTest.php +++ b/plugins/bc-mail/tests/TestCase/View/Helper/MailformHelperTest.php @@ -10,13 +10,24 @@ */ namespace BcMail\Test\TestCase\View\Helper; +use BaserCore\Service\ContentsService; +use BaserCore\Service\ContentsServiceInterface; +use BaserCore\Test\Factory\ContentFactory; +use BaserCore\Test\Factory\SiteFactory; use BaserCore\TestSuite\BcTestCase; +use BaserCore\View\BcFrontAppView; +use BaserCore\View\Helper\BcBaserHelper; use BcMail\Model\Entity\MailField; +use BcMail\Test\Factory\MailContentFactory; +use BcMail\Test\Factory\MailFieldsFactory; use BcMail\Test\Factory\MailMessagesFactory; use BcMail\Service\MailFieldsServiceInterface; +use BcMail\View\Helper\BcMailBaserHelper; use BcMail\View\Helper\MailformHelper; use BcMail\Test\Scenario\MailContentsScenario; use BcMail\Test\Scenario\MailFieldsScenario; +use BcMail\View\Helper\MailHelper; +use BcMail\View\MailFrontAppView; use Cake\ORM\ResultSet; use Cake\View\View; use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; @@ -71,7 +82,23 @@ public function testCreate() */ public function testAuthCaptcha() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + //データ生成 + SiteFactory::make(['id' => 1])->persist(); + ContentFactory::make(['plugin' => 'BcMail', 'type' => 'MailContent', 'entity_id' => 1, 'url' => '/contact/', 'site_id' => 1, 'lft' => 1, 'rght' => 2])->persist(); + MailContentFactory::make(['id' => 1, 'form_template' => 'default', 'mail_template' => 'mail_default'])->persist(); + + //準備 + $view = new MailFrontAppView($this->getRequest('/contact/')); + $view->setPlugin('BcMail'); + $options['helper'] = new BcBaserHelper($view); + $this->MailformHelper = new MailformHelper($view); + + //対象メッソどを呼ぶ + ob_start(); + $this->MailformHelper->authCaptcha('auth_captcha', $options); + $result = ob_get_clean(); + //戻る値を確認 + $this->assertTextContains(' alt="認証画像" class="auth-captcha-image"', $result); } /** From 353fec37657727d4e60d5d95e497a8ca4cf4deb9 Mon Sep 17 00:00:00 2001 From: HungDV2022 Date: Wed, 11 Dec 2024 10:38:41 +0900 Subject: [PATCH 2/2] =?UTF-8?q?MailformHelper::authCaptcha()=20=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 --- .../tests/TestCase/View/Helper/MailformHelperTest.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/plugins/bc-mail/tests/TestCase/View/Helper/MailformHelperTest.php b/plugins/bc-mail/tests/TestCase/View/Helper/MailformHelperTest.php index 39692e659c..51e2844f1f 100644 --- a/plugins/bc-mail/tests/TestCase/View/Helper/MailformHelperTest.php +++ b/plugins/bc-mail/tests/TestCase/View/Helper/MailformHelperTest.php @@ -10,23 +10,17 @@ */ namespace BcMail\Test\TestCase\View\Helper; -use BaserCore\Service\ContentsService; -use BaserCore\Service\ContentsServiceInterface; use BaserCore\Test\Factory\ContentFactory; use BaserCore\Test\Factory\SiteFactory; use BaserCore\TestSuite\BcTestCase; -use BaserCore\View\BcFrontAppView; use BaserCore\View\Helper\BcBaserHelper; use BcMail\Model\Entity\MailField; use BcMail\Test\Factory\MailContentFactory; -use BcMail\Test\Factory\MailFieldsFactory; use BcMail\Test\Factory\MailMessagesFactory; use BcMail\Service\MailFieldsServiceInterface; -use BcMail\View\Helper\BcMailBaserHelper; use BcMail\View\Helper\MailformHelper; use BcMail\Test\Scenario\MailContentsScenario; use BcMail\Test\Scenario\MailFieldsScenario; -use BcMail\View\Helper\MailHelper; use BcMail\View\MailFrontAppView; use Cake\ORM\ResultSet; use Cake\View\View;