Skip to content

Commit

Permalink
MailContentsController::edit() ユニットテスト
Browse files Browse the repository at this point in the history
  • Loading branch information
dovanhung committed Dec 13, 2024
1 parent 378a8e8 commit 9be8c21
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function initialize(): void
* @param int ブログコンテンツID
* @checked
* @noTodo
* @unitTest
*/
public function edit(MailContentsAdminServiceInterface $service, int $id)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

namespace BcMail\Test\TestCase\Controller\Admin;

use BaserCore\Test\Factory\ContentFactory;
use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcContainerTrait;
Expand Down Expand Up @@ -90,7 +89,23 @@ public function test_delete()
*/
public function testAdmin_edit()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
$this->enableSecurityToken();
$this->enableCsrfToken();
//データーを生成
$mailContentServices = $this->getService(MailContentsServiceInterface::class);
//データを生成
$this->loadFixtureScenario(MailContentsScenario::class);
//Postデータを生成
$mailContent = $mailContentServices->get(1);
$mailContent->description = 'this is api edit';
//対象URLをコル
$this->post('/baser/admin/bc-mail/mail_contents/edit/1', $mailContent->toArray());
$this->assertResponseCode(302);
$this->assertFlashMessage('メールフォーム「お問い合わせ」を更新しました。');

//エラーを発生した場合
$this->post('/baser/admin/bc-mail/mail_contents/edit/222', $mailContent->toArray());
$this->assertResponseCode(404);
}

/**
Expand Down

0 comments on commit 9be8c21

Please sign in to comment.