Skip to content

Commit

Permalink
middlewareの定義のテスト修正およびより効率的なmiddleware登録メソッドへの変更
Browse files Browse the repository at this point in the history
  • Loading branch information
ゴンドー committed Oct 5, 2023
1 parent e9276f7 commit 3bc8d85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/baser-core/src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ function loadPlugin(PluginApplicationInterface $application, $plugin, $priority)
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
{
$middlewareQueue
->prepend(new BcRequestFilterMiddleware())
->insertBefore(CsrfProtectionMiddleware::class, new AuthenticationMiddleware($this))
->insertBefore(AuthenticationMiddleware::class, new BcRequestFilterMiddleware($this))
->add(new BcAdminMiddleware())
->add(new BcFrontMiddleware())
->add(new BcRedirectSubSiteFilter());
Expand Down
5 changes: 3 additions & 2 deletions plugins/baser-core/tests/TestCase/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
use BaserCore\Service\SiteConfigsServiceInterface;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcUtil;
use BaserCore\Middleware\BcRequestFilterMiddleware;
use Cake\Core\Configure;
use Cake\Core\Container;
use Cake\Event\EventManager;
use Cake\Http\Middleware\CsrfProtectionMiddleware;
use Cake\Http\MiddlewareQueue;
use Authentication\Middleware\AuthenticationMiddleware;
use Cake\Routing\Router;
use Cake\Filesystem\File;

Expand Down Expand Up @@ -176,7 +176,8 @@ public function testMiddleware(): void
$middleware = new MiddlewareQueue();
$middleware->add(CsrfProtectionMiddleware::class);
$middlewareQueue = $this->Plugin->middleware($middleware);
$this->assertInstanceOf(AuthenticationMiddleware::class, $middlewareQueue->current());
$this->assertInstanceOf(BcRequestFilterMiddleware::class, $middlewareQueue->current());
$this->assertEquals(6, $middlewareQueue->count());
}

/**
Expand Down

0 comments on commit 3bc8d85

Please sign in to comment.