25 lines
819 B
PHP
25 lines
819 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Events\AdvertisingStopped;
|
|
use App\Models\AdWallet;
|
|
use App\Models\Tenant;
|
|
use App\Services\Advertising\AdStopAllService;
|
|
use App\Services\Advertising\AdWalletGate;
|
|
use Illuminate\Support\Facades\Event;
|
|
|
|
it('reports insufficient when free balance cannot cover active holds', function () {
|
|
$tenant = Tenant::factory()->create();
|
|
AdWallet::create(['tenant_id' => $tenant->id, 'balance_rub' => '100.00', 'frozen_rub' => '2500.00']);
|
|
|
|
$gate = app(AdWalletGate::class);
|
|
expect($gate->isSolvent($tenant->id))->toBeFalse();
|
|
});
|
|
|
|
it('dispatches AdvertisingStopped when stopping all advertising', function () {
|
|
Event::fake();
|
|
app(AdStopAllService::class)->stopAll(123);
|
|
Event::assertDispatched(AdvertisingStopped::class, fn ($e) => $e->tenantId === 123);
|
|
});
|