Add has_landing plus landing_* deploy keys, deduct balance on withdraw request, keep app_url for SMS login links, and clarify Zarin rial wallet document titles. Co-authored-by: Cursor <cursoragent@cursor.com>
82 lines
2.9 KiB
PHP
82 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Services\ConfigService;
|
|
use App\Services\SuperAdminProgramSettingsOverlay;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class SuperAdminProgramSettingsOverlayTest extends TestCase
|
|
{
|
|
public function test_owned_keys_match_the_access_flag_list(): void
|
|
{
|
|
$expected = [
|
|
'customer_direct_sms',
|
|
'customer_special_pricing',
|
|
'enable_automation',
|
|
'enable_conditional_order',
|
|
'enable_customer_level_profit',
|
|
'enable_gold_credit',
|
|
'enable_product_funds',
|
|
'group_sms',
|
|
'has_landing',
|
|
'has_page_earn_money',
|
|
'has_page_gift_card',
|
|
'has_page_notification',
|
|
'has_page_price_trigger',
|
|
'jibit_enabled',
|
|
'permision__enabled',
|
|
'show_to_users_chat',
|
|
];
|
|
|
|
$this->assertSame($expected, SuperAdminProgramSettingsOverlay::SUPERADMIN_OWNED_KEYS);
|
|
$this->assertCount(16, SuperAdminProgramSettingsOverlay::SUPERADMIN_OWNED_KEYS);
|
|
}
|
|
|
|
public function test_overlay_keeps_only_access_keys(): void
|
|
{
|
|
$map = SuperAdminProgramSettingsOverlay::ownedItemsMap([
|
|
['key' => 'enable_automation', 'value' => 'true'],
|
|
['key' => 'jibit_enabled', 'value' => 'false'],
|
|
['key' => 'price_provider', 'value' => 'zaarbox'],
|
|
['key' => 'show_last_price', 'value' => 'false'],
|
|
['key' => 'close_price', 'value' => 'true'],
|
|
['key' => 'startDay', 'value' => '11:00'],
|
|
['key' => 'endDay', 'value' => '20:30'],
|
|
['key' => 'name_fa', 'value' => 'طلا'],
|
|
['key' => 'montzar_live_price', 'value' => '168000000'],
|
|
['key' => 'tracking_systems', 'value' => '[]'],
|
|
['key' => '', 'value' => 'x'],
|
|
'not-an-array',
|
|
]);
|
|
|
|
$this->assertSame(['enable_automation', 'jibit_enabled'], array_keys($map));
|
|
$this->assertSame('true', $map['enable_automation']['value']);
|
|
$this->assertArrayNotHasKey('price_provider', $map);
|
|
$this->assertArrayNotHasKey('show_last_price', $map);
|
|
}
|
|
|
|
public function test_tenant_keys_are_never_superadmin_owned(): void
|
|
{
|
|
$tenantKeys = array_merge(
|
|
ConfigService::TRADING_HOURS_CLIENT_KEYS,
|
|
SuperAdminProgramSettingsOverlay::RUNTIME_KEYS,
|
|
SuperAdminProgramSettingsOverlay::LOCAL_OWNED_KEYS,
|
|
[
|
|
'price_provider',
|
|
'zaarbox_price_key',
|
|
'montzar_base_url',
|
|
'name_fa',
|
|
'name_en',
|
|
]
|
|
);
|
|
|
|
foreach ($tenantKeys as $key) {
|
|
$this->assertFalse(
|
|
SuperAdminProgramSettingsOverlay::isSuperAdminOwned($key),
|
|
"{$key} نباید از سوپرادمین خوانده شود"
|
|
);
|
|
}
|
|
}
|
|
}
|