moon / fakemiddleware
一个用于在测试环境中禁用中间件的Laravel 5小包
1.1
2015-04-28 01:09 UTC
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-09-18 09:11:02 UTC
README
有时候当你测试Laravel 5中的控制器时,你可能想要禁用中间件/路由中间件。这个包简化了这一过程。
安装
composer require --dev "moon/fakemiddleware": "1.1"
用法
打开默认随L5一起提供的 TestCase.php 文件。找到 createApplication 方法并初始化 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; }