From 0d77dd5d6b89d616050ec5bccea4476942ea2c56 Mon Sep 17 00:00:00 2001 From: HungDV2022 Date: Wed, 18 Dec 2024 13:15:04 +0900 Subject: [PATCH] =?UTF-8?q?MailMessagesController::attachment()=20?= =?UTF-8?q?=E3=83=A6=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 | 2 +- .../Admin/MailMessagesControllerTest.php | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/plugins/bc-mail/src/Controller/Admin/MailMessagesController.php b/plugins/bc-mail/src/Controller/Admin/MailMessagesController.php index b759698b92..3ccf5bed9d 100644 --- a/plugins/bc-mail/src/Controller/Admin/MailMessagesController.php +++ b/plugins/bc-mail/src/Controller/Admin/MailMessagesController.php @@ -163,6 +163,7 @@ public function delete( * @return void * @checked * @noTodo + * @unitTest */ public function attachment(MailMessagesServiceInterface $service) { @@ -189,7 +190,6 @@ public function attachment(MailMessagesServiceInterface $service) } Header(sprintf('Content-type: %s; name=%s', $mineType, $file)); echo file_get_contents($filePath); - exit(); } /** diff --git a/plugins/bc-mail/tests/TestCase/Controller/Admin/MailMessagesControllerTest.php b/plugins/bc-mail/tests/TestCase/Controller/Admin/MailMessagesControllerTest.php index ac0ac55444..56d9c04280 100644 --- a/plugins/bc-mail/tests/TestCase/Controller/Admin/MailMessagesControllerTest.php +++ b/plugins/bc-mail/tests/TestCase/Controller/Admin/MailMessagesControllerTest.php @@ -207,7 +207,24 @@ public function testDelete() */ public function testAttachment() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); + $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'])); + + ob_start(); + $this->get('/baser/admin/bc-mail/mail_messages/attachment/1/00000002_tel.jpg'); + $actualIsHelp = ob_get_clean(); + $this->assertNotEmpty($actualIsHelp); + + //不要テーブルを削除 + $MailMessagesService->dropTable(1); } /**