Skip to content

moon0326/FakeMiddleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FakeMiddleware

Sometimes you want to disable a middleware/route middleware when testing a controller in Laravel 5. This package simplifies the process.

Installation

composer require --dev "moon/fakemiddleware": "1.1"

Usage

Open TestCase.php, which comes with L5 by default. Locate createApplication method and initialize FakeMiddleware.

use Moon\FakeMiddleware\FakeMiddleware;

public function createApplication()
{
    $app = require __DIR__.'/../bootstrap/app.php';
    $app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();

    // This will remove ExternalOAuthVerifier and repalce auth middleware
    // with a fake middleware
    // function __construct(Application $app, $globalMiddlewares, $routeMiddlewares);
    new FakeMiddleware($app, ['App\Http\Middleware\ExternalOAuthVerifier'], ['auth']);

    return $app;
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages