diff --git a/plugins/bc-mail/src/Controller/Admin/MailFieldsController.php b/plugins/bc-mail/src/Controller/Admin/MailFieldsController.php index 0adbcfa531..c434b0f9e0 100644 --- a/plugins/bc-mail/src/Controller/Admin/MailFieldsController.php +++ b/plugins/bc-mail/src/Controller/Admin/MailFieldsController.php @@ -174,6 +174,7 @@ public function add(MailFieldsAdminServiceInterface $service, int $mailContentId * @return void * @checked * @noTodo + * @unitTest */ public function edit(MailFieldsAdminServiceInterface $service, int $mailContentId, int $id) { diff --git a/plugins/bc-mail/tests/TestCase/Controller/Admin/MailFieldsControllerTest.php b/plugins/bc-mail/tests/TestCase/Controller/Admin/MailFieldsControllerTest.php index ab672cd9ec..752551fa14 100644 --- a/plugins/bc-mail/tests/TestCase/Controller/Admin/MailFieldsControllerTest.php +++ b/plugins/bc-mail/tests/TestCase/Controller/Admin/MailFieldsControllerTest.php @@ -18,6 +18,7 @@ use BcMail\Controller\Admin\MailFieldsController; use BcMail\Service\Admin\MailFieldsAdminServiceInterface; use BcMail\Service\MailMessagesServiceInterface; +use BcMail\Test\Factory\MailFieldsFactory; use BcMail\Test\Scenario\MailContentsScenario; use BcMail\Test\Scenario\MailFieldsScenario; use Cake\Event\Event; @@ -94,7 +95,34 @@ public function testAdmin_add() */ public function testAdmin_edit() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + $this->enableSecurityToken(); + $this->enableCsrfToken(); + //テストデータベースを生成 + $this->loadFixtureScenario(MailContentsScenario::class); + $this->loadFixtureScenario(MailFieldsScenario::class); + //data edit + $data = [ + 'name' => 'edit', + 'type' => 'text' + ]; + //対象URLをコル + $this->post('/baser/admin/bc-mail/mail_fields/edit/1/1', $data); + //check response code + $this->assertResponseCode(302); + //check flash message + $this->assertFlashMessage('メールフィールド「edit」を更新しました。'); + //check redirect + $this->assertRedirect('/baser/admin/bc-mail/mail_fields/index/1'); + //case error + $data = [ + 'name' => null, + 'type' => 'text' + ]; + //対象URLをコル + $this->post('/baser/admin/bc-mail/mail_fields/edit/1/1', $data); + //check response code + $this->assertResponseCode(200); + $this->assertResponseContains('入力エラーです。内容を修正してください。'); } /**