Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.8] Create getter for the http route middlewares #27852

Merged
merged 1 commit into from
Mar 11, 2019
Merged

[5.8] Create getter for the http route middlewares #27852

merged 1 commit into from
Mar 11, 2019

Conversation

roberto-aguilar
Copy link
Contributor

This getter allows to create tests for the route middlewares, which is currently not possible because the property is protected.

For example, if you want to ensure that a route middleware has been registered, with this getter you can write:

/** @test */
public function it_registers_a_custom_route_middleware()
{
    $middlewares = resolve(\App\Http\Kernel::class)->getRouteMiddleware();

    $this->assertArrayHasKey('custom', $middlewares);
    $this->assertEquals(\App\Http\Middleware\Custom::class, $middlewares['custom']);
}

This is similar to #26268 but for the $routeMiddleware property.

@driesvints driesvints changed the title Create getter for the http route middlewares [5.8] Create getter for the http route middlewares Mar 11, 2019
This getter allows to create tests for the route
middlewares, which is currently not possible
because the property is protected.

For example, if you want to ensure that a route middleware has been
registered, with this getter you can write:

```php
/** @test */
public function it_registers_a_custom_route_middleware()
{
    $middlewares = resolve(\App\Http\Kernel::class)->getRouteMiddleware();

    $this->assertArrayHasKey('custom', $middlewares);
    $this->assertEquals(\App\Http\Middleware\Custom::class, $middlewares['custom']);
}
```
@taylorotwell taylorotwell merged commit fe2c8a6 into laravel:5.8 Mar 11, 2019
@roberto-aguilar roberto-aguilar deleted the feature/http-kernel branch March 11, 2019 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants