<?php
use App\Application\Services\OutboxService; use App\Models\OutboxMessage; use Illuminate\Support\Facades\DB;
it('rolls back outbox records with the owning transaction',function(){try{DB::transaction(function(){app(OutboxService::class)->record('invoice','pay_test','payment.finished',['payment_id'=>'pay_test']);throw new RuntimeException('rollback');});}catch(RuntimeException){}expect(OutboxMessage::count())->toBe(0);});
it('persists an event committed with its financial state transaction',function(){DB::transaction(fn()=>app(OutboxService::class)->record('invoice','pay_test','payment.finished',['payment_id'=>'pay_test']));expect(OutboxMessage::where('aggregate_id','pay_test')->exists())->toBeTrue();});
