diff --git a/plugins/bc-mail/src/Controller/Admin/MailMessagesController.php b/plugins/bc-mail/src/Controller/Admin/MailMessagesController.php index c102d212d6..b759698b92 100644 --- a/plugins/bc-mail/src/Controller/Admin/MailMessagesController.php +++ b/plugins/bc-mail/src/Controller/Admin/MailMessagesController.php @@ -199,6 +199,7 @@ public function attachment(MailMessagesServiceInterface $service) * @return void * @checked * @noTodo + * @unitTest */ public function download_csv(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 cd25a95477..ac0ac55444 100644 --- a/plugins/bc-mail/tests/TestCase/Controller/Admin/MailMessagesControllerTest.php +++ b/plugins/bc-mail/tests/TestCase/Controller/Admin/MailMessagesControllerTest.php @@ -209,4 +209,28 @@ public function testAttachment() { $this->markTestIncomplete('このテストは、まだ実装されていません。'); } + + /** + * test download_csv + */ + public function testDownloadCsv() + { + $this->enableSecurityToken(); + $this->enableCsrfToken(); + //データを生成 + $MailMessagesService = $this->getService(MailMessagesServiceInterface::class); + $MailMessagesService->createTable(1); + MailContentFactory::make(['id' => 1])->persist(); + ContentFactory::make(['name' => 'name_test', 'plugin' => 'BcMail', 'type' => 'MailContent', 'entity_id' => 1])->persist(); + $mailMessageTable = TableRegistry::getTableLocator()->get('mail_message_1'); + $mailMessageTable->save(new Entity(['id' => 1, 'created' => '2016-07-29 18:02:53', 'modified' => '2020-09-14 21:10:41'])); + $mailMessageTable->save(new Entity(['id' => 2, 'created' => '2016-07-29 18:02:53', 'modified' => '2020-09-14 21:10:41'])); + + //対象メソッドをテスト + $this->get('/baser/admin/bc-mail/mail_messages/download_csv/1'); + $this->assertResponseCode(200); + + //不要テーブルを削除 + $MailMessagesService->dropTable(1); + } }