create('test.txt', 1024, 'text/plain'); $dto = new FileDTO( modelType: 'User', modelId: '123', relationName: 'avatar', directory: 'avatars', disk: 'public', options: [], uploaderId: 'user1' ); // We expect File::create to be called. Since File is a model, we can mock it or use a database transaction if we had RefreshDatabase // Let's use a simple mock for File if possible or just use the database $action = new UploadAndAttachFile(); $result = $action->execute($file, $dto); expect($result)->toBeInstanceOf(File::class) ->and($result->name)->toBe('test.txt') ->and($result->disk)->toBe('public'); Storage::disk('public')->assertExists($result->path); });