Create tests for app/Settings
This commit is contained in:
parent
dc8ad3a905
commit
fad7e1199e
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
use App\Models\SiteSetting;
|
||||
use App\Settings;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
it('can call itself for getting a setting', function () {
|
||||
expect(Settings::registrationCode())->toBe('secret');
|
||||
});
|
||||
|
||||
it('can load settings from the database', function () {
|
||||
Settings::$settings = null;
|
||||
Settings::loadSettings();
|
||||
expect(Settings::$settings['registrationCode'])->toBe('secret');
|
||||
});
|
||||
|
||||
it('can return a setting value', function () {
|
||||
expect(Settings::get('registrationCode'))->toBe('secret');
|
||||
});
|
||||
|
||||
it('can return a setting value, loading from DB if not in class', function () {
|
||||
Settings::clearSettings();
|
||||
expect(Settings::get('registrationCode'))->toBe('secret');
|
||||
});
|
||||
|
||||
it('can modify a setting in the database', function () {
|
||||
Settings::set('registrationCode', 'new');
|
||||
expect(SiteSetting::where('setting_key', 'registrationCode')->first()->setting_value)->toBe('new')
|
||||
->and(Settings::get('registrationCode'))->toBe('new');
|
||||
});
|
||||
|
||||
it('can clear settings from the class', function () {
|
||||
Settings::clearSettings();
|
||||
expect(Settings::$settings)->toBeNull();
|
||||
});
|
||||
Loading…
Reference in New Issue