/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Integration/Routing/WithoutMiddlewareAttributeTest.php
62 строки
2 KB
JurianArie
[13.x] Add WithoutMiddleware controller middleware attribute (#60709)
09 июл 2026, 15:59
Не верифицирован
09 июл 2026, 15:59
8136d58
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Integration\Routing; use Illuminate\Routing\Attributes\Controllers\WithoutMiddleware; use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; class WithoutMiddlewareAttributeTest extends TestCase { public function test_attribute_without_middleware_is_respected(): void { $route = Route::get('/', [WithoutMiddlewareAttributeController::class, 'index']); $this->assertEquals([ 'all', 'only-index', 'also-index', ], $route->excludedMiddleware()); $route = Route::get('/', [WithoutMiddlewareAttributeController::class, 'show'])->withoutMiddleware('merged'); $this->assertEquals([ 'merged', 'all', 'except-index', ], $route->excludedMiddleware()); $route = Route::get('/', [ChildWithoutMiddlewareAttributeController::class, 'index']); $this->assertEquals([ 'all', 'only-index', 'also-index', ], $route->excludedMiddleware()); $route = Route::get('/', [ChildWithoutMiddlewareAttributeController::class, 'show'])->withoutMiddleware('merged'); $this->assertEquals([ 'merged', 'all', 'except-index', ], $route->excludedMiddleware()); } } #[WithoutMiddleware('all')] #[WithoutMiddleware('only-index', only: ['index'])] #[WithoutMiddleware('except-index', except: ['index'])] class WithoutMiddlewareAttributeController { #[WithoutMiddleware('also-index')] public function index(): void { // ... } public function show(): void { // ... } } class ChildWithoutMiddlewareAttributeController extends WithoutMiddlewareAttributeController { }