<?php

namespace App\Tests\Entity;

use App\Entity\Product;
use App\Entity\ProductDoc;
use PHPUnit\Framework\TestCase;

class ProductDocTest extends TestCase
{
    public function testGettersAndSetters()
    {
        $productDoc = new ProductDoc();
        $product = new Product();
        $now = new \DateTimeImmutable();

        $productDoc->setProduct($product);
        $productDoc->setName('Document 1');
        $productDoc->setIsPublic(true);
        $productDoc->setDocProductName('doc1.pdf');
        $productDoc->setDocProductSize(1024);
        $productDoc->setUpdatedAt($now);

        $this->assertSame($product, $productDoc->getProduct());
        $this->assertEquals('Document 1', $productDoc->getName());
        $this->assertTrue($productDoc->isPublic());
        $this->assertEquals('doc1.pdf', $productDoc->getDocProductName());
        $this->assertEquals(1024, $productDoc->getDocProductSize());
        $this->assertSame($now, $productDoc->getUpdatedAt());
    }

    public function testJson()
    {
        $product = new Product();
        $product->setName('Main Product');
        
        $productDoc = new ProductDoc();
        $productDoc->setProduct($product);
        $productDoc->setName('Doc Name');

        $expectedJson = json_encode([
            'name' => 'Doc Name',
            'product' => 'Main Product',
        ]);

        $this->assertEquals($expectedJson, $productDoc->json());
    }
}
