38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?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();
|
|
});
|