Skip to content

Commit

Permalink
MailFieldsController::beforeFilter() ユニットテスト
Browse files Browse the repository at this point in the history
  • Loading branch information
dovanhung committed Dec 17, 2024
1 parent d0dba2d commit 52b87b0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function initialize(): void
* @return void
* @checked
* @noTodo
* @unitTest
*/
public function beforeFilter(EventInterface $event)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
namespace BcMail\Test\TestCase\Controller\Admin;

use BaserCore\Service\BcDatabaseServiceInterface;
use BaserCore\Test\Factory\ContentFactory;
use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcContainerTrait;
use BcMail\Controller\Admin\MailFieldsController;
use BcMail\Service\Admin\MailFieldsAdminServiceInterface;
use BcMail\Service\MailFieldsServiceInterface;
use BcMail\Service\MailMessagesServiceInterface;
use BcMail\Test\Factory\MailFieldsFactory;
use BcMail\Test\Scenario\MailContentsScenario;
Expand Down Expand Up @@ -75,7 +74,31 @@ public function testInitialize()
*/
public function testBeforeFilter()
{
$this->markTestIncomplete('このテストは、まだ実装されていません。');
ContentFactory::make([
'name' => 'name_test',
'plugin' => 'BcMail',
'type' => 'MailContent',
'url' => '/contact/',
'site_id' => 1,
'title' => 'お問い合わせ',
'entity_id' => 1
])->persist();

//正常テスト・エラーにならない
$request = $this->getRequest('/baser/admin/bc-mail/mail_fields/view/1/1');
$request = $this->loginAdmin($request);
$this->MailFieldsController = new MailFieldsController($request);
$event = new Event('filter');
$this->MailFieldsController->beforeFilter($event);

//異常テスト
$request = $this->getRequest('/baser/admin/bc-mail/mail_fields/view/2222/1');
$request = $this->loginAdmin($request);
$this->MailFieldsController = new MailFieldsController($request);
$event = new Event('filter');
$this->expectExceptionMessage('コンテンツデータが見つかりません。');
$this->expectException('BaserCore\Error\BcException');
$this->MailFieldsController->beforeFilter($event);
}

/**
Expand Down

0 comments on commit 52b87b0

Please sign in to comment.