<?php

declare(strict_types=1);

namespace Ferienpass\AdminBundle\Tests\Dto;

use Ferienpass\AdminBundle\Dto\HostRegistrationDto;
use PHPUnit\Framework\TestCase;

final class HostRegistrationDtoTest extends TestCase
{
    public function testToUserCreatesUserWithDtoProperties(): void
    {
        $dto = new HostRegistrationDto();
        $dto->firstname = 'John';
        $dto->lastname = 'Doe';
        $dto->userEmail = 'john@example.com';

        $user = $dto->toUser();

        self::assertSame('John', $user->getFirstname());
        self::assertSame('Doe', $user->getLastname());
        self::assertSame('john@example.com', $user->getEmail());
    }

    public function testToHostCreatesHostWithDtoProperties(): void
    {
        $dto = new HostRegistrationDto();
        $dto->name = 'My Organization';
        $dto->email = 'org@example.com';
        $dto->website = 'https://example.com';
        $dto->text = 'Description';

        $host = $dto->toHost();

        self::assertSame('My Organization', $host->getName());
        self::assertSame('org@example.com', $host->getEmail());
        self::assertSame('https://example.com', $host->getWebsite());
        self::assertSame('Description', $host->getText());
    }

    public function testToHostAddsPostalAddress(): void
    {
        $dto = new HostRegistrationDto();
        $dto->name = 'Test Org';
        $dto->street = 'Main Street 1';
        $dto->postal = '12345';
        $dto->city = 'Berlin';

        $host = $dto->toHost();

        self::assertCount(1, $host->getPostalAddresses());
    }
}
