moon / fakemiddleware
A small Laravel 5 package to disable a middleware in testing environment
Installs: 24 929
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=5.4.0
Requires (Dev)
- mockery/mockery: 0.9.*
- orchestra/testbench: 3.0.6
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-10-30 09:36:21 UTC
README
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; }