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

zaster's avatar

Response status code [302] is not a successful status code. Failed asserting that false is true.

<?php

namespace Tests\Feature;

use App\Models\PreCost;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
use Tests\TestCase;

class PreCostFormTest extends TestCase
{

    use RefreshDatabase;

    /** @test */
    public function employee_section_quotation_page_contains_livewire_component()
    {
        $this->get('/employee/quotations')
            ->assertSuccessful();
            //->assertSeeLivewire('pre-cost-form');
    }

gives this error

Response status code [302] is not a successful status code.
  Failed asserting that false is true.

The Actual URL looks like this

http://127.0.0.1:8000/employee/quotations

0 likes
6 replies
mvd's avatar
mvd
Best Answer
Level 48

@zaster

Oke, then the 302 status make sense. You are not logged in in your test, so /employee/quotations will redirect to the login page.

You also need to login in the test.

Something like:

 $this->be(User::factory()->create())
			->get('/employee/quotations')
            ->assertSuccessful();
zaster's avatar

@mvd

I checked that and it gives the below error (User Creation works in tinker)

 Response status code [403] is not a successful status code.
  Failed asserting that false is true.
mvd's avatar

Are you using permission functionlity for users or do users have to meet certain criteria?

zaster's avatar

@mvd yes. That was the issue. Solved. Thank you very much.

1 like

Please or to participate in this conversation.