<?php

namespace App\Tests\Entity;

use App\Entity\User;
use App\Entity\Customer;
use App\Entity\Website;
use App\Entity\WebsiteConfiguration;
use PHPUnit\Framework\TestCase;

class WebsiteConfigurationTest extends TestCase
{
    private function makeWebsite(): Website
    {
        $user = new User();
        $user->setEmail('t@t.com');
        $user->setFirstName('A');
        $user->setLastName('B');
        $user->setPassword('h');
        $customer = new Customer($user);

        return new Website($customer, 'Test Site');
    }

    public function testConstructor(): void
    {
        $website = $this->makeWebsite();
        $config = new WebsiteConfiguration($website, 'theme', 'dark');

        $this->assertNull($config->getId());
        $this->assertSame($website, $config->getWebsite());
        $this->assertSame('theme', $config->getType());
        $this->assertSame('dark', $config->getValue());
    }

    public function testSetType(): void
    {
        $config = new WebsiteConfiguration($this->makeWebsite(), 'theme', 'dark');
        $result = $config->setType('color');
        $this->assertSame('color', $config->getType());
        $this->assertSame($config, $result);
    }

    public function testSetValue(): void
    {
        $config = new WebsiteConfiguration($this->makeWebsite(), 'theme', 'dark');
        $result = $config->setValue('light');
        $this->assertSame('light', $config->getValue());
        $this->assertSame($config, $result);
    }
}
