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.7] Create getter for the http middleware groups #26268

Merged
merged 1 commit into from
Oct 26, 2018
Merged

[5.7] Create getter for the http middleware groups #26268

merged 1 commit into from
Oct 26, 2018

Conversation

roberto-aguilar
Copy link
Contributor

@roberto-aguilar roberto-aguilar commented Oct 26, 2018

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

For example, if you want to ensure that the web group is using a middleware to track utm campaigns, with this getter you can write:

/** @test */
public function it_registers_the_track_utm_middleware_in_the_web_group()
{
    $groups = resolve(\App\Http\Kernel::class)->getMiddlewareGroups();

    $this->assertContains(\App\Http\Middleware\TrackUTM::class, $groups['web']);
}

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

For example, if you want to ensure that the web group is using a
middleware to track utm campaigns, with this getter you can write:

```php
/** @test */
public function it_registers_the_track_utm_middleware_in_the_web_group()
{
    $groups = resolve(\App\Http\Kernel::class)->getMiddlewareGroups();

    $this->assertContains(\App\Http\Middleware\TrackUTM::class, $groups['web']);
}
```
@taylorotwell taylorotwell merged commit 07648ae into laravel:5.7 Oct 26, 2018
@roberto-aguilar roberto-aguilar deleted the feature/http-kernel branch October 26, 2018 19:21
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.

2 participants