Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Elliot_putt's avatar

PHP Unit Invalid route action

Hi, All My Tests were running perfect last week then I ran them again after a little coding and now get this error it seems very general but I can't solve it.

I Can run my Store ,Update, and Destroy methods and they pass but the get actions for Index,Create and Show Fail.

UnexpectedValueException : Invalid route action: [request].
/**
     * @test
     * @dataProvider requests
     */
    public function test_Global_Users_Are_Allowed_User_Access(Closure $sendRequest)
    {
        $this->withoutExceptionHandling();
        //User Trying to complete the action
        $this->login(User::factory()->global()->create());

        //Model trying to be accessed
        $user = User::factory()->temporary()->create();

        /** @var TestResponse $response */
        $response = $sendRequest->call($this, $user);

        //expected Response
        $this->assertTrue(in_array($response->status(), [200, 302]));
    }

    public function requests(): \Generator
    {
        yield [fn(User $user) => $this->get(action([\App\Http\Controllers\UserController::class, 'index']))];
        yield [fn(User $user) => $this->get(action([\App\Http\Controllers\UserController::class, 'create']))];
        yield [fn(User $user) => $this->get(action([\App\Http\Controllers\UserController::class, 'show'], $user->id))];
        yield [fn(User $user) => $this->post(action([\App\Http\Controllers\UserController::class, 'store']))];
        yield [fn(User $user) => $this->patch(action([\App\Http\Controllers\UserController::class, 'update'], $user->id))];
        yield [fn(User $user) => $this->delete(action([\App\Http\Controllers\UserController::class, 'destroy'], $user->id))];

    }
0 likes
6 replies
click's avatar

... after a little coding ...

Did you change anything in this controller or in your web routes file? Is only your test failing or is your interface also failing? Did you do any package upgrades, like upgrading Laravel to another major version? Can you see in the exception trace where this error is coming from. The trace should you give an idea where the error starts and probably also how to resolve it.

1 like
Elliot_putt's avatar

@click thanks for the reply could you point me in the direction of how to look at the exception trace ? Yes a bit of coding has been changed , and packages upgraded but not laravel unfortunately.

sr57's avatar
sr57
Best Answer
Level 39

@elliot_putt

Remove $this->withoutExceptionHandling(); to see the logs.

1 like
Elliot_putt's avatar

@sr57 Thanks this got my logs to come up and I found a few bugs I didn't even know I had I never knew test errors show in logs!

But this didn't solve my problem.

Found out I had a function called request in my UserController which was messing it up weird.

 Route::get("/users/{user}/request", "request")->name("users.request");

Please or to participate in this conversation.