Laravel PHPUnit mock Request
问题 I'm doing a PHPUnit on my controller and I can't seem to mock the Request right. Here's the Controller: use Illuminate\Http\Request; public function insert(Request $request) { // ... some codes here if ($request->has('username')) { $userEmail = $request->get('username'); } else if ($request->has('email')) { $userEmail = $request->get('email'); } // ... some codes here } Then on the unit test, public function testIndex() { // ... some codes here $requestParams = [ 'username' => 'test', 'email'