31 lines
825 B
PHP
31 lines
825 B
PHP
<?php
|
|
|
|
use App\Models\LotterySetting;
|
|
use App\Services\LotterySettings;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
test('lottery settings get returns seeded value', function (): void {
|
|
LotterySettings::put('fixture.flag', true, 'test', null);
|
|
|
|
expect(LotterySettings::get('fixture.flag'))->toBeTrue();
|
|
});
|
|
|
|
test('lottery settings misses are not cached', function (): void {
|
|
Cache::flush();
|
|
|
|
expect(LotterySettings::get('not.exists', 'fallback'))->toBe('fallback');
|
|
|
|
LotterySetting::query()->create([
|
|
'setting_key' => 'not.exists',
|
|
'value_json' => 'hello',
|
|
'group_name' => 'test',
|
|
]);
|
|
|
|
LotterySettings::forgetKey('not.exists');
|
|
|
|
expect(LotterySettings::get('not.exists'))->toBe('hello');
|
|
});
|