Aplikasi Keuangan yang mengatur lalu lintas transaksi antara bank dan aplikasi internal Kampus
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

42 lines
1.3 KiB

<?php
use App\Domains\System\Actions\Settings\UpdateSettings;
use App\Domains\System\DTOs\SystemSetingDTO;
use App\Domains\System\Enums\SystemSettingKey;
use App\Domains\System\Models\SystemSettings;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Cache;
uses(RefreshDatabase::class);
test('it updates string setting', function () {
$action = new UpdateSettings();
$dto = new SystemSetingDTO(SystemSettingKey::WEB_NAME, 'New Name');
$action->execute($dto);
expect(SystemSettings::where('key', SystemSettingKey::WEB_NAME->value)->value('value'))->toBe('New Name');
});
test('it updates existing setting', function () {
SystemSettings::create([
'key' => SystemSettingKey::WEB_NAME->value,
'value' => 'Old Name',
]);
$action = new UpdateSettings();
$dto = new SystemSetingDTO(SystemSettingKey::WEB_NAME, 'New Name');
$action->execute($dto);
expect(SystemSettings::where('key', SystemSettingKey::WEB_NAME->value)->value('value'))->toBe('New Name');
});
test('it clears cache after update', function () {
Cache::shouldReceive('forget')->once()->with('system_settings');
$action = new UpdateSettings();
$dto = new SystemSetingDTO(SystemSettingKey::WEB_NAME, 'New Name');
$action->execute($dto);
});