From my situation, I need to test my request validation rules, but here is a problem, I think I DO NOT make a request to the real route, so I have to create a fake controller and add to my test case, here is my solution.

/**
 * @dataProvider resend
 */
public function testOrderResendRequest($payload, $assertions)
{
    $route = Route::addRoute('POST', 'fake/resend', '\Tests\Feature\FakeController@resend')
        ->prefix('api')->name('fake.resend');
    $this->json('POST', $route->uri, $payload)
        ->assertJsonValidationErrors($assertions);
}

I added a route to request, and also making a fake controller in the test case, finally, I did a json request to the fake route. By the way, I used @dataProvider to validate any situations I wanted to test properties, it’s really useful.

Next, I made FakeController in the same class.

class FakeController extends Controller
{
    public function resend(OrderResendRequest $request) // Here is my request layer.
    {
        return response()->json(['data' => 'hello']); // whatever you wanted putting in.
    }
}

public function testOrderResendRequest($payload, $assertions)

What do I need to do this? I used validator()->make(), I can’t validate Rule, for example, Rule:requireIf and others closures, if your rules are only having string rules, you can do for:

$rules = (new OrderResendRequest)->rules();
$validator = validator()->make($payload, $rules);

$this->assertFalse($validator->fails());
// and what you want to test