Skip to content

Commit

Permalink
Merge pull request #4070 from HungDV2022/unittest_MailMessagesControl…
Browse files Browse the repository at this point in the history
…ler_index

MailMessagesController::index() ユニットテスト
  • Loading branch information
HungDV2022 authored Dec 9, 2024
2 parents bf0b013 + b8a51e5 commit 7c56b32
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function beforeFilter(EventInterface $event)
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function index(MailMessagesAdminServiceInterface $service, int $mailContentId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
use BcMail\Controller\Admin\MailMessagesController;
use BcMail\Service\MailMessagesServiceInterface;
use BcMail\Test\Factory\MailContentFactory;
use Cake\Event\Event;
use Cake\TestSuite\IntegrationTestTrait;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;
Expand Down Expand Up @@ -103,7 +105,26 @@ public function testBeforeRender()
*/
public function testIndex()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
$this->enableSecurityToken();
$this->enableCsrfToken();
// メールメッセージのデータを作成する
ContentFactory::make([
'plugin' => 'BcMail',
'type' => 'MailContent',
'url' => '/contact/',
'site_id' => 1,
'title' => 'お問い合わせ',
'entity_id' => 1,
])->persist();
MailContentFactory::make(['id' => 1])->persist();
$MailMessagesService = $this->getService(MailMessagesServiceInterface::class);
//テストデータベースを生成
$MailMessagesService->createTable(1);

//正常テスト
$this->get('/baser/admin/bc-mail/mail_messages/index/1');
$this->assertResponseOk();
$MailMessagesService->dropTable(1);
}

/**
Expand Down

0 comments on commit 7c56b32

Please sign in to comment.