Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b126dc

Browse files
committed
Fix the forgetMiddleware call (to not use get_class)
1 parent e3c12b6 commit 6b126dc

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/Illuminate/Foundation/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ public function forgetMiddleware($class)
716716
{
717717
$this->middlewares = array_filter($this->middlewares, function($m) use ($class)
718718
{
719-
return get_class($m['class']) != $class;
719+
return $m['class'] != $class;
720720
});
721721
}
722722

tests/Foundation/FoundationApplicationTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ public function testServiceProvidersAreCorrectlyRegistered()
3838
}
3939

4040

41+
public function testForgetMiddleware()
42+
{
43+
$app = new ApplicationGetMiddlewaresStub;
44+
$app->middleware('Illuminate\Http\FrameGuard');
45+
$app->forgetMiddleware('Illuminate\Http\FrameGuard');
46+
$this->assertEquals(0, count($app->getMiddlewares()));
47+
}
48+
4149
public function testDeferredServicesMarkedAsBound()
4250
{
4351
$app = new Application;
@@ -136,6 +144,14 @@ protected function setExceptionHandler(Closure $handler) { return $handler; }
136144

137145
}
138146

147+
class ApplicationGetMiddlewaresStub extends Illuminate\Foundation\Application
148+
{
149+
public function getMiddlewares()
150+
{
151+
return $this->middlewares;
152+
}
153+
}
154+
139155
class ApplicationDeferredSharedServiceProviderStub extends Illuminate\Support\ServiceProvider {
140156
protected $defer = true;
141157
public function register()

0 commit comments

Comments
 (0)