Skip to content

Commit

Permalink
Merge pull request #4077 from HungDV2022/unittest_MailformHelper_auth…
Browse files Browse the repository at this point in the history
…Captcha

MailformHelper::authCaptcha() ユニットテスト
  • Loading branch information
HungDV2022 authored Dec 17, 2024
2 parents d0dba2d + 353fec3 commit 55af800
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
?>


<?php if (!$freezed): ?>
<?php if (!isset($freezed) || !$freezed): ?>
<div class="bs-mail-form-auth-captcha">
<div>
<?php $this->BcBaser->img($captchaUrl, ['alt' => __d('baser_core', '認証画像'), 'class' => $options['class']]) ?>
Expand Down
1 change: 1 addition & 0 deletions plugins/bc-mail/src/View/Helper/MailformHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ public function create($context = null, $options = []): string
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function authCaptcha(string $fieldName, array $options = [])
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@
*/
namespace BcMail\Test\TestCase\View\Helper;

use BaserCore\Test\Factory\ContentFactory;
use BaserCore\Test\Factory\SiteFactory;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\View\Helper\BcBaserHelper;
use BcMail\Model\Entity\MailField;
use BcMail\Test\Factory\MailContentFactory;
use BcMail\Test\Factory\MailMessagesFactory;
use BcMail\Service\MailFieldsServiceInterface;
use BcMail\View\Helper\MailformHelper;
use BcMail\Test\Scenario\MailContentsScenario;
use BcMail\Test\Scenario\MailFieldsScenario;
use BcMail\View\MailFrontAppView;
use Cake\ORM\ResultSet;
use Cake\View\View;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;
Expand Down Expand Up @@ -71,7 +76,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);
}

/**
Expand Down

0 comments on commit 55af800

Please sign in to comment.