<?php

declare(strict_types=1);

use App\Support\SystemSettings;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;

uses(Tests\TestCase::class, DatabaseTransactions::class);

it('читает bool-флаг из system_settings', function () {
    DB::table('system_settings')->updateOrInsert(
        ['key' => 'billing_yookassa_enabled'],
        ['value' => 'true', 'type' => 'bool', 'updated_at' => now()]
    );

    expect(SystemSettings::bool('billing_yookassa_enabled'))->toBeTrue();
});

it('возвращает default если ключа нет', function () {
    DB::table('system_settings')->where('key', 'no_such_flag_xyz')->delete();

    expect(SystemSettings::bool('no_such_flag_xyz', false))->toBeFalse();
});
