Skip to content

Commit

Permalink
MailController::captcha() ユニットテスト
Browse files Browse the repository at this point in the history
  • Loading branch information
TPGF00003 committed Nov 12, 2024
1 parent f7fab89 commit 03d2cf6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugins/bc-mail/src/Controller/MailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,12 @@ public function thanks(MailFrontServiceInterface $service, MailContentsServiceIn
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function captcha(BcCaptchaServiceInterface $service, string $token)
{
$this->viewBuilder()->disableAutoLayout();
$service->render($this->getRequest(), $token);
exit();
}

}
11 changes: 10 additions & 1 deletion plugins/bc-mail/tests/TestCase/Controller/MailControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
use BaserCore\Utility\BcContainerTrait;
use BcMail\Test\Factory\MailContentFactory;
use BcMail\Test\Factory\MailFieldsFactory;
use BcMail\View\Helper\MailformHelper;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\View\View;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;

class MailControllerTest extends BcTestCase
Expand Down Expand Up @@ -188,7 +190,14 @@ public function test_back()
*/
public function testCaptcha()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
$this->loadFixtureScenario(InitAppScenario::class);
ContentFactory::make(['id' => 1, '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();

//正常テスト
ob_start();
$this->get('/contact/captcha/38763366');
$this->assertNotNull(ob_get_clean());
}

/**
Expand Down

0 comments on commit 03d2cf6

Please sign in to comment.