Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiodekker committed Sep 30, 2020
1 parent 55136dd commit 1e4ae86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,8 @@ protected function registerMiddleware()
if (method_exists($kernel, 'appendMiddlewareToGroup')) {
$kernel->appendMiddlewareToGroup($group, Middleware::class);

return;
}

// Laravel >= 5.4.4 && < 6.9.0
if ($this->app[Router::class]->hasMiddlewareGroup($group)) {
} elseif ($this->app[Router::class]->hasMiddlewareGroup($group)) {
$this->app[Router::class]->pushMiddlewareToGroup($group, Middleware::class);
}
}
Expand Down
10 changes: 7 additions & 3 deletions tests/ServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ public function test_route_macro_is_registered()

public function test_middleware_is_registered_to_the_web_group()
{
$route = Route::middleware('web')->get('/');
$middleware = App::make(Router::class)->gatherRouteMiddleware($route);
$webRoute = Route::middleware('web')->get('/');
$apiRoute = Route::middleware('api')->get('/');

$this->assertContains(Middleware::class, $middleware);
$webMiddleware = App::make(Router::class)->gatherRouteMiddleware($webRoute);
$apiMiddleware = App::make(Router::class)->gatherRouteMiddleware($apiRoute);

$this->assertContains(Middleware::class, $webMiddleware);
$this->assertNotContains(Middleware::class, $apiMiddleware);
}

public function test_validation_errors_are_registered()
Expand Down

0 comments on commit 1e4ae86

Please sign in to comment.