A framework upgrade that moved middleware registration from an array to a fluent configuration, where the order is no longer visible in one place.
public function test_the_api_middleware_order_is_unchanged(): void
{
$router = $this->app->make(Router::class);
self::assertSame([
EnsureApiVersion::class,
ThrottleRequests::class . ':api',
SubstituteBindings::class,
], $router->getMiddlewareGroups()['api']);
}
The order matters — a rate limiter after route binding does a database lookup for a request it is about to reject — and after the upgrade it is the result of several calls rather than a literal array. Asserting the resolved order is the only way to know the migration preserved it, and the test is now the documentation of what the order is supposed to be.