Skip to content

Commit

Permalink
Add unitTest_MailMessagesController_download (#3983)
Browse files Browse the repository at this point in the history
Co-authored-by: thangnn <[email protected]>
  • Loading branch information
thangnnmd and thangnn authored Nov 7, 2024
1 parent 92067ca commit d8b2b37
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ public function batch(MailMessagesServiceInterface $service, $mailContentId)
*
* @checked
* @noTodo
* @unitTest
*/
public function download(MailMessagesAdminServiceInterface $service, int $mailContentId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ public function getViewVarsForView(int $mailContentId, int $mailMessageId)
*/
public function getViewVarsForDownloadCsv(int $mailContentId, ServerRequest $request)
{
$currentContent = $request->getAttribute('currentContent');
$this->setup($mailContentId);
return [
'encoding' => $request->getQuery('encoding') ?? 'utf-8',
'messages' => $this->MailMessages->convertMessageToCsv($this->getIndex()->all()->toArray()),
'contentName' => $request->getAttribute('currentContent')?->name,
'contentName' => $currentContent ? $request->getAttribute('currentContent')?->name : '',
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,18 @@ public function testBatch()
*/
public function testDownload()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
// メールメッセージのデータを作成する
$MailMessagesService = $this->getService(MailMessagesServiceInterface::class);
//テストデータベースを生成
$MailMessagesService->createTable(1);
$mailMessageTable = TableRegistry::getTableLocator()->get('BcMail.MailMessages');
$mailContentId = 1;
$mailMessageTable->setup($mailContentId);
$mailMessageTable->save(new Entity(['id' => 2]));

ob_start();
$this->get("/baser/api/admin/bc-mail/mail_messages/download/1.json?token=$this->accessToken");
$actual = ob_get_clean();
$this->assertNotEmpty($actual);
}
}

0 comments on commit d8b2b37

Please sign in to comment.