diff --git a/plugins/bc-mail/src/Controller/Admin/MailMessagesController.php b/plugins/bc-mail/src/Controller/Admin/MailMessagesController.php index a5c45f74ff..2d2129bdec 100644 --- a/plugins/bc-mail/src/Controller/Admin/MailMessagesController.php +++ b/plugins/bc-mail/src/Controller/Admin/MailMessagesController.php @@ -81,6 +81,7 @@ public function beforeFilter(EventInterface $event) * @return void * @checked * @noTodo + * @unitTest */ public function index(MailMessagesAdminServiceInterface $service, int $mailContentId) { diff --git a/plugins/bc-mail/tests/TestCase/Controller/Admin/MailMessagesControllerTest.php b/plugins/bc-mail/tests/TestCase/Controller/Admin/MailMessagesControllerTest.php index 855390103d..002460464c 100644 --- a/plugins/bc-mail/tests/TestCase/Controller/Admin/MailMessagesControllerTest.php +++ b/plugins/bc-mail/tests/TestCase/Controller/Admin/MailMessagesControllerTest.php @@ -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; @@ -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); } /**