fix tests

This commit is contained in:
Dan Harrin
2026-07-12 16:18:57 +01:00
parent 87c294aaf8
commit 08f1a5caa3
2 changed files with 17 additions and 8 deletions
@@ -1,5 +1,6 @@
<?php
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Filament\Tests\Fixtures\Models\User;
use Filament\Tests\TestCase;
@@ -10,6 +11,21 @@ use Illuminate\Support\Facades\URL;
uses(TestCase::class, RefreshDatabase::class);
// A real importer so the controller can resolve `$import->importer` (e.g. for the
// `shouldPreventFormulaInjection()` static call) instead of a non-existent class string.
class DownloadFailureTestImporter extends Importer
{
public static function getColumns(): array
{
return [];
}
public static function getCompletedNotificationBody(Import $import): string
{
return '';
}
}
// Policy that grants `view` access to any user, so that a non-owner can download.
class AllowImportViewPolicy
{
@@ -33,7 +49,7 @@ function createImportForOwner(User $owner): Import
return Import::create([
'file_name' => 'import.csv',
'file_path' => 'imports/import.csv',
'importer' => 'App\\Filament\\Imports\\TestImporter',
'importer' => DownloadFailureTestImporter::class,
'total_rows' => 1,
'successful_rows' => 0,
'user_id' => $owner->getKey(),
@@ -59,13 +59,6 @@ describe('`shouldPreventFormulaInjection()`', function (): void {
});
describe('failure CSV formula injection', function (): void {
beforeEach(function (): void {
$migrations = dirname(__DIR__, 4) . '/packages/actions/database/migrations';
(include "{$migrations}/create_imports_table.php")->up();
(include "{$migrations}/create_failed_import_rows_table.php")->up();
});
$downloadFailureCsv = function (string $importer): string {
$user = User::factory()->create();
$this->actingAs($user);