Files
portal/app/tests/Feature/Admin/ProxyMarketBalanceRowTest.php
T

33 lines
1.2 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
uses(DatabaseTransactions::class);
beforeEach(function () {
DB::table('external_service_balances')->delete();
});
it('GET /api/admin/dashboard/balances показывает proxy_market со сроком «до …» и остатком дней', function () {
config()->set('services.proxy_market.expires_at', now()->addDays(18)->format('Y-m-d'));
config()->set('services.proxy_market.topup_url', 'https://proxy.market/');
DB::table('external_service_balances')->insert([
'service_key' => 'proxy_market', 'currency' => 'RUB',
'light' => 'green', 'ok' => true,
'checked_at' => now(), 'created_at' => now(), 'updated_at' => now(),
]);
$resp = $this->getJson('/api/admin/dashboard/balances');
$resp->assertOk();
$row = collect($resp->json('services'))->firstWhere('service_key', 'proxy_market');
expect($row)->not->toBeNull();
expect($row['expires_at'])->toBe(now()->addDays(18)->format('d.m.Y'));
expect($row['days_left'])->toBe(18);
expect($row['topup_url'])->toBe('https://proxy.market/');
});