diff --git a/plugins/bc-mail/src/Controller/Admin/MailFieldsController.php b/plugins/bc-mail/src/Controller/Admin/MailFieldsController.php index 153fd49efe..4ac5e7ce23 100644 --- a/plugins/bc-mail/src/Controller/Admin/MailFieldsController.php +++ b/plugins/bc-mail/src/Controller/Admin/MailFieldsController.php @@ -54,6 +54,7 @@ public function initialize(): void * @return void * @checked * @noTodo + * @unitTest */ public function beforeFilter(EventInterface $event) { diff --git a/plugins/bc-mail/tests/TestCase/Controller/Admin/MailFieldsControllerTest.php b/plugins/bc-mail/tests/TestCase/Controller/Admin/MailFieldsControllerTest.php index ce15e3ccdf..3a7ea2a053 100644 --- a/plugins/bc-mail/tests/TestCase/Controller/Admin/MailFieldsControllerTest.php +++ b/plugins/bc-mail/tests/TestCase/Controller/Admin/MailFieldsControllerTest.php @@ -13,12 +13,11 @@ namespace BcMail\Test\TestCase\Controller\Admin; use BaserCore\Service\BcDatabaseServiceInterface; +use BaserCore\Test\Factory\ContentFactory; use BaserCore\Test\Scenario\InitAppScenario; use BaserCore\TestSuite\BcTestCase; use BaserCore\Utility\BcContainerTrait; use BcMail\Controller\Admin\MailFieldsController; -use BcMail\Service\Admin\MailFieldsAdminServiceInterface; -use BcMail\Service\MailFieldsServiceInterface; use BcMail\Service\MailMessagesServiceInterface; use BcMail\Test\Factory\MailFieldsFactory; use BcMail\Test\Scenario\MailContentsScenario; @@ -75,7 +74,31 @@ public function testInitialize() */ public function testBeforeFilter() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + ContentFactory::make([ + 'name' => 'name_test', + 'plugin' => 'BcMail', + 'type' => 'MailContent', + 'url' => '/contact/', + 'site_id' => 1, + 'title' => 'お問い合わせ', + 'entity_id' => 1 + ])->persist(); + + //正常テスト・エラーにならない + $request = $this->getRequest('/baser/admin/bc-mail/mail_fields/view/1/1'); + $request = $this->loginAdmin($request); + $this->MailFieldsController = new MailFieldsController($request); + $event = new Event('filter'); + $this->MailFieldsController->beforeFilter($event); + + //異常テスト + $request = $this->getRequest('/baser/admin/bc-mail/mail_fields/view/2222/1'); + $request = $this->loginAdmin($request); + $this->MailFieldsController = new MailFieldsController($request); + $event = new Event('filter'); + $this->expectExceptionMessage('コンテンツデータが見つかりません。'); + $this->expectException('BaserCore\Error\BcException'); + $this->MailFieldsController->beforeFilter($event); } /**