From 31d0d281db4e1ba8c72c05264eba4c7a567f0f47 Mon Sep 17 00:00:00 2001 From: HungDV2022 Date: Thu, 12 Dec 2024 11:35:44 +0900 Subject: [PATCH] =?UTF-8?q?MailformHelper::download=5Fcsv()=20=E3=83=A6?= =?UTF-8?q?=E3=83=8B=E3=83=83=E3=83=88=E3=83=86=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/MailMessagesController.php | 1 + .../Admin/MailMessagesControllerTest.php | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) 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); + } }