Skip to content

Commit

Permalink
Merge pull request #3976 from thangnnmd/unitTest_BcFrontAppController…
Browse files Browse the repository at this point in the history
…_beforeFilter

BcFrontAppController::beforeFilter() ユニットテストユニットテスト
  • Loading branch information
HungDV2022 authored Nov 8, 2024
2 parents 8f9ceba + be1b41a commit 9a10616
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions plugins/baser-core/src/Controller/BcFrontAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function initialize(): void
* @return Response|void
* @checked
* @noTodo
* @unitTest
*/
public function beforeFilter(EventInterface $event)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
namespace BaserCore\Test\TestCase\Controller;

use BaserCore\Controller\BcFrontAppController;
use BaserCore\Test\Factory\ContentFactory;
use BaserCore\Test\Factory\PluginFactory;
use BaserCore\Test\Factory\SiteFactory;
use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcContainer;
use Cake\Core\Configure;
use Cake\Event\Event;
use Cake\I18n\I18n;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;

/**
Expand Down Expand Up @@ -88,7 +90,14 @@ public function testNotFound()
*/
public function testBeforeFilter()
{
$this->markTestIncomplete('このテストはまだ実装されていません。');
//準備
ContentFactory::make(['url' => '/', 'site_id' => 2])->persist();
SiteFactory::make(['id' => 2, 'lang' => 'english'])->persist();
$this->BcFrontAppController->setRequest($this->loginAdmin($this->getRequest('/')));
//テスト
$this->BcFrontAppController->beforeFilter(new Event('Controller.beforeFilter', $this->BcFrontAppController));
//language check
$this->assertEquals('en', I18n::getLocale());
}

/**
Expand Down

0 comments on commit 9a10616

Please sign in to comment.