Skip to content

Commit

Permalink
Merge pull request #3991 from thangnnmd/unitTest_MaiController_thanks
Browse files Browse the repository at this point in the history
MaiController::thanks ユニットテスト
  • Loading branch information
HungDV2022 authored Nov 8, 2024
2 parents 6797907 + d78cb29 commit d841096
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/bc-mail/src/Controller/MailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ public function submit(
* @return void|ResponseInterface
* @checked
* @noTodo
* @unitTest
*/
public function thanks(MailFrontServiceInterface $service, MailContentsServiceInterface $mailContentsService)
{
Expand Down
19 changes: 19 additions & 0 deletions plugins/bc-mail/tests/TestCase/Controller/MailControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use BaserCore\Test\Factory\ContentFactory;
use BaserCore\Test\Factory\SiteConfigFactory;
use BaserCore\Test\Factory\SiteFactory;
use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcContainerTrait;
use BcMail\Test\Factory\MailContentFactory;
Expand Down Expand Up @@ -188,4 +189,22 @@ public function testCaptcha()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
}

/**
* [PUBIC] メール送信完了
*/
public function test_thanks()
{
$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();

$this->session(['BcMail.MailContent' => MailContentFactory::get(1)]);
//正常テスト
$this->get('/contact/thanks');

$this->assertResponseOk();
$vars = $this->_controller->viewBuilder()->getVars();
$this->assertNotNull($vars['mailContent']);
}
}

0 comments on commit d841096

Please sign in to comment.