qcod / laravel-app-settings

Store settings in database with a manager UI for your Laravel app
MIT License
339 stars 53 forks source link

PHPUnit Testing / Initialize Settings #51

Open muhzak opened 4 months ago

muhzak commented 4 months ago

During unit testing, if I load a fresh set of settings, it returns empty. How do I make sure it initializes to the default settings without having to save them one time? I don't want to depend on the cache.

muhzak commented 4 months ago

I figured it out. I had to set data_type to boolean in addition to 'type' as boolean.

Also I noticed when you call settings()->all() or (new \QCod\AppSettings\Setting\AppSettings(settings())->all();

It gives you the database values instead of the cast values -- which should be the case for (new \QCod\AppSettings\Setting\AppSettings(settings()))->all();

unless I am mistaken.