ana
ana
FFilament
Created by ana on 10/16/2023 in #❓┊help
Error running tests: Call to a member function getId() on null
laravel v10 filament v3 pest project was updated from L9 and F2 One of the test that fails with that message: Tests\Feature\Back\Files\CreateTest.php
<?php

use App\Filament\Resources\FileResource;
use function Pest\Livewire\livewire;
use App\Models\User;
use App\Models\File;

it('redirects to login for guest', function () {
test()->get(FileResource::getUrl('create'))
->assertStatus(302)
->assertRedirect(route('filament.auth.login'));
});
<?php

use App\Filament\Resources\FileResource;
use function Pest\Livewire\livewire;
use App\Models\User;
use App\Models\File;

it('redirects to login for guest', function () {
test()->get(FileResource::getUrl('create'))
->assertStatus(302)
->assertRedirect(route('filament.auth.login'));
});
tests\TestCase.php
<?php

namespace Tests;

use App\Providers\Filament\AppPanelProvider;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
use LazilyRefreshDatabase;

}
<?php

namespace Tests;

use App\Providers\Filament\AppPanelProvider;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
use LazilyRefreshDatabase;

}
Thank you
16 replies