<?php

namespace App\Tests\Entity;

use App\Entity\Payout;
use App\Entity\User;
use PHPUnit\Framework\TestCase;

class PayoutTest extends TestCase
{
    public function testNewPayoutHasCreatedAt(): void
    {
        $payout = new Payout();

        self::assertInstanceOf(\DateTimeImmutable::class, $payout->getCreatedAt());
    }

    public function testPayoutFields(): void
    {
        $user = new User();
        $arrival = new \DateTimeImmutable('2026-03-20');

        $payout = new Payout();
        $result = $payout->setOrganizer($user)
            ->setStripePayoutId('po_test123')
            ->setStatus('paid')
            ->setAmount(15000)
            ->setCurrency('eur')
            ->setDestination('ba_xxx')
            ->setStripeAccountId('acct_xxx')
            ->setArrivalDate($arrival);

        self::assertSame($payout, $result);
        self::assertNull($payout->getId());
        self::assertSame($user, $payout->getOrganizer());
        self::assertSame('po_test123', $payout->getStripePayoutId());
        self::assertSame('paid', $payout->getStatus());
        self::assertSame(15000, $payout->getAmount());
        self::assertSame(150.0, $payout->getAmountDecimal());
        self::assertSame('eur', $payout->getCurrency());
        self::assertSame('ba_xxx', $payout->getDestination());
        self::assertSame('acct_xxx', $payout->getStripeAccountId());
        self::assertSame($arrival, $payout->getArrivalDate());
    }
}
