Skip to content

Commit

Permalink
Merge pull request #4089 from HungDV2022/unittest_MailMessagesControl…
Browse files Browse the repository at this point in the history
…ler_attachment

MailMessagesController::attachment() ユニットテスト
  • Loading branch information
HungDV2022 authored Dec 20, 2024
2 parents 021d4cc + 0d77dd5 commit 63acce0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public function delete(
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function attachment(MailMessagesServiceInterface $service)
{
Expand All @@ -189,7 +190,6 @@ public function attachment(MailMessagesServiceInterface $service)
}
Header(sprintf('Content-type: %s; name=%s', $mineType, $file));
echo file_get_contents($filePath);
exit();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 63acce0

Please sign in to comment.