Skip to content

Commit

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

MailMessagesController::download_csv() ユニットテスト
  • Loading branch information
HungDV2022 authored Dec 17, 2024
2 parents 55af800 + 31d0d28 commit 049c995
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public function attachment(MailMessagesServiceInterface $service)
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function download_csv(MailMessagesAdminServiceInterface $service, int $mailContentId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 049c995

Please sign in to comment.