Settings fake still connects to the database
Roboroads opened this issue · 2 comments
For our project, we explicitly wipe de database for unittests so that unittests are sure to not use the database, this is what feature tests are for.
I expected that using SomeSettingsClass::fake(/*needed values for this test*/);
would just register this singleton and not use the database since it doesn't have to load (or save) values. However, it does:
Illuminate\Database\QueryException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'testing.settings' doesn't exist (Connection: mysql, SQL: select `name`, `payload` from `settings` where `group` = group)
// Some laravel query builder frames
at vendor/spatie/laravel-settings/src/SettingsRepositories/DatabaseSettingsRepository.php:28
at vendor/spatie/laravel-settings/src/SettingsMapper.php:86
at vendor/spatie/laravel-settings/src/Settings.php:62
at tests/Unit/Settings/SomeSettingsTest.php:6 // <------ SomeSettingsClass::fake();
// Testtuite bootup frames
Hi, I have same issue. How can I prevent all settings from loading automatically?
The package will load in extra settings which were not faked, so you can only provide a part of the faked settings and rely on the defaults within the migrations.
That being said, it should be possible to completely fake the settings so I've added this in our newest release.