/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Integration/Routing/MiddlewareAttributeTest.php
43 строки
1 KB
JurianArie
[13.x] Add controller middleware attribute (#59030)
01 мар 2026, 17:14
Не верифицирован
01 мар 2026, 17:14
33d3b85
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Integration\Routing; use Illuminate\Routing\Attributes\Controllers\Middleware; use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; class MiddlewareAttributeTest extends TestCase { public function test_attribute_middleware_is_respected(): void { $route = Route::get('/', [MiddlewareAttributeController::class, 'index']); $this->assertEquals([ 'all', 'only-index', 'also-index', ], $route->controllerMiddleware()); $route = Route::get('/', [MiddlewareAttributeController::class, 'show']); $this->assertEquals([ 'all', 'except-index', ], $route->controllerMiddleware()); } } #[Middleware('all')] #[Middleware('only-index', only: ['index'])] #[Middleware('except-index', except: ['index'])] class MiddlewareAttributeController { #[Middleware('also-index')] public function index(): void { // ... } public function show(): void { // ... } }