<?php

declare(strict_types=1);

use App\Models\BalanceTransaction;
use App\Models\Tenant;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;

uses(TestCase::class, DatabaseTransactions::class);

it('accepts type=migration after CHECK constraint extension', function () {
    /** @var Tenant $tenant */
    $tenant = Tenant::factory()->create(['balance_rub' => '1000.00']);

    $tx = BalanceTransaction::create([
        'tenant_id' => $tenant->id,
        'type' => BalanceTransaction::TYPE_MIGRATION,
        'amount_leads' => -5,
        'amount_rub' => '600.00',
        'balance_leads_after' => 0,
        'balance_rub_after' => '1600.00',
        'description' => 'test migration',
    ]);

    expect($tx->type)->toBe('migration');
});

it('exposes TYPE_MIGRATION constant', function () {
    expect(BalanceTransaction::TYPE_MIGRATION)->toBe('migration');
});
