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

ouissla's avatar

Missing property when using spatie/laravel-settings when running tests

HI,

I am using laravel-settings 2.1 on a Laravel 8 project, and it has been working fine until now. I need a new setting, so I created a migration:

<?php

use Spatie\LaravelSettings\Migrations\SettingsMigration;

class AddOnboardingVersionSetting extends SettingsMigration
{
    public function up(): void
    {
        $this->migrator->add('general.onboarding_version', 2);
    }
};

I updated my GeneralSettings class:

<?php

namespace App\Settings;

use App\Helpers\CarbonIntervalCast;
use Carbon\CarbonInterval;
use Spatie\LaravelSettings\Settings;

class GeneralSettings extends Settings
{
    public int $onboarding_version;

    public static function group(): string
    {
        return 'general';
    }
}

And I can use it successfully in the code.

When I am running tests with phpunit and Sqlite, all my tests fails with the following error: Tried loading settings 'App\Settings\GeneralSettings', and following properties were missing: onboarding_version

I was running tests in memory. I switched to a .sqlite file and noticed that my setting is never set in the database, like Sqlite ignores my migration.

There are more settings in this class, and they are all created successfully and cause no issues. Any ideas?

1 like
1 reply

Please or to participate in this conversation.