Files
portal/app/tests/Feature/Advertising/AdWalletTopupTest.php
T
2026-07-24 20:40:41 +03:00

21 lines
708 B
PHP

<?php
declare(strict_types=1);
use App\Models\AdWallet;
use App\Models\Tenant;
use App\Services\Advertising\AdWalletService;
it('tops up ad wallet and writes a transaction', function () {
$tenant = Tenant::factory()->create();
AdWallet::create(['tenant_id' => $tenant->id, 'balance_rub' => '0.00', 'frozen_rub' => '0.00']);
app(AdWalletService::class)->topup($tenant->id, '1000.00', channel: null, description: 'ЮKassa');
$wallet = AdWallet::where('tenant_id', $tenant->id)->first();
expect($wallet->balance_rub)->toBe('1000.00');
$this->assertDatabaseHas('ad_wallet_transactions', [
'tenant_id' => $tenant->id, 'type' => 'topup', 'amount_rub' => '1000.00',
]);
});