Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings fake still connects to the database #225

Closed
Roboroads opened this issue Jun 13, 2023 · 2 comments
Closed

Settings fake still connects to the database #225

Roboroads opened this issue Jun 13, 2023 · 2 comments

Comments

@Roboroads
Copy link

Roboroads commented Jun 13, 2023

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
@Roboroads Roboroads changed the title Using a settings fake a database connection is still made Settings fake still connects to the database Jun 13, 2023
@TheAndrey
Copy link

Hi, I have same issue. How can I prevent all settings from loading automatically?

@rubenvanassche
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants