<?php

namespace App\Tests\Entity;

use App\Entity\Formules;
use App\Entity\FormulesOptionsInclus;
use App\Entity\FormulesProductInclus;
use App\Entity\FormulesRestriction;
use PHPUnit\Framework\TestCase;

class FormulesTest extends TestCase
{
    public function testGettersAndSetters()
    {
        $formules = new Formules();
        $now = new \DateTimeImmutable();

        $formules->setName('Test Formule');
        $formules->setImageName('image.jpg');
        $formules->setImageSize(1024);
        $formules->setUpdatedAt($now);
        $formules->setType('package');
        $formules->setIsPublish(true);
        $formules->setDescription('Formule description');
        $formules->setPrice1j(100.0);
        $formules->setPrice2j(150.0);
        $formules->setPrice5j(300.0);
        $formules->setCaution(50.0);
        $formules->setPos(1);

        $this->assertEquals('Test Formule', $formules->getName());
        $this->assertEquals('image.jpg', $formules->getImageName());
        $this->assertEquals(1024, $formules->getImageSize());
        $this->assertSame($now, $formules->getUpdatedAt());
        $this->assertEquals('package', $formules->getType());
        $this->assertTrue($formules->isPublish());
        $this->assertEquals('Formule description', $formules->getDescription());
        $this->assertEquals(100.0, $formules->getPrice1j());
        $this->assertEquals(150.0, $formules->getPrice2j());
        $this->assertEquals(300.0, $formules->getPrice5j());
        $this->assertEquals(50.0, $formules->getCaution());
        $this->assertEquals(1, $formules->getPos());
    }

    public function testSlug()
    {
        $formules = new Formules();
        // $formules->setId(1); // ID is auto-generated, cannot be set directly in unit test
        $formules->setName('Test Formule');

        $this->assertEquals('-test-formule', $formules->slug()); // ID will be null
    }

    public function testFormulesProductInclusesCollection()
    {
        $formules = new Formules();
        $productInclus = new FormulesProductInclus();

        $this->assertCount(0, $formules->getFormulesProductIncluses());
        $formules->addFormulesProductInclus($productInclus);
        $this->assertCount(1, $formules->getFormulesProductIncluses());
        $this->assertSame($formules, $productInclus->getFormules());

        $formules->removeFormulesProductInclus($productInclus);
        $this->assertCount(0, $formules->getFormulesProductIncluses());
        $this->assertNull($productInclus->getFormules());
    }

    public function testFormulesOptionsInclusesCollection()
    {
        $formules = new Formules();
        $optionInclus = new FormulesOptionsInclus();

        $this->assertCount(0, $formules->getFormulesOptionsIncluses());
        $formules->addFormulesOptionsInclus($optionInclus);
        $this->assertCount(1, $formules->getFormulesOptionsIncluses());
        $this->assertSame($formules, $optionInclus->getFormule());

        $formules->removeFormulesOptionsInclus($optionInclus);
        $this->assertCount(0, $formules->getFormulesOptionsIncluses());
        $this->assertNull($optionInclus->getFormule());
    }

    public function testSetFormulesRestriction()
    {
        $formules = new Formules();
        $restriction = new FormulesRestriction();

        $this->assertNull($formules->getFormulesRestriction());
        $formules->setFormulesRestriction($restriction);
        $this->assertSame($restriction, $formules->getFormulesRestriction());
        $this->assertSame($formules, $restriction->getFormule());

        $formules->setFormulesRestriction(null);
        $this->assertNull($formules->getFormulesRestriction());
        $this->assertNull($restriction->getFormule());
    }
}
