<?php

namespace Tests\Unit\Element;

use App\Element\Element;
use App\Set\Set as DomainSet;
use Tests\TestCase;

class ElementTest extends TestCase
{
    public function testCreatesElementWithNullableParent(): void
    {
        $set = new DomainSet(
            id: 1,
            name: 'Daily learning',
            description: 'Daily learning description',
            iconImageUrl: '/assets/daily-learning-icon.svg',
        );
        $rootElement = new Element(
            id: 1,
            title: 'Root',
            set: $set,
            parentElement: null,
        );
        $childElement = new Element(
            id: 2,
            title: 'Child',
            set: $set,
            parentElement: $rootElement,
        );

        $this->assertSame(2, $childElement->getId());
        $this->assertSame('Child', $childElement->getTitle());
        $this->assertSame($set, $childElement->getSet());
        $this->assertSame($rootElement, $childElement->getParentElement());
        $this->assertNull($rootElement->getParentElement());
    }
}
