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

Conversation

Projects
None yet
2 participants
@roberto-aguilar
Copy link
Contributor

roberto-aguilar commented 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:

/** @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.

@roberto-aguilar roberto-aguilar force-pushed the roberto-aguilar:feature/http-kernel branch from 5e8515d to 7773a50 Mar 11, 2019

@driesvints driesvints changed the title Create getter for the http route middlewares [5.8] Create getter for the http route middlewares Mar 11, 2019

Create getter for the http route middlewares
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']);
}
```

@roberto-aguilar roberto-aguilar force-pushed the roberto-aguilar:feature/http-kernel branch from 7773a50 to 8412218 Mar 11, 2019

@taylorotwell taylorotwell merged commit fe2c8a6 into laravel:5.8 Mar 11, 2019

2 checks passed

continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@roberto-aguilar roberto-aguilar deleted the roberto-aguilar:feature/http-kernel branch Mar 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.