<?php
namespace Tests\Unit\admin\Controllers;

use PHPUnit\Framework\TestCase;
use admin\Controllers\ProductArchiveController;
use Domain\Product\ProductRepository;

class ProductArchiveControllerTest extends TestCase
{
    private $mockRepository;
    private $controller;

    protected function setUp(): void
    {
        $this->mockRepository = $this->createMock(ProductRepository::class);
        $this->controller = new ProductArchiveController($this->mockRepository);
    }

    public function testConstructorAcceptsRepository(): void
    {
        $controller = new ProductArchiveController($this->mockRepository);
        $this->assertInstanceOf(ProductArchiveController::class, $controller);
    }

    public function testHasListMethod(): void
    {
        $this->assertTrue(method_exists($this->controller, 'list'));
    }

    public function testHasUnarchiveMethod(): void
    {
        $this->assertTrue(method_exists($this->controller, 'unarchive'));
    }

    public function testListMethodReturnType(): void
    {
        $reflection = new \ReflectionClass($this->controller);
        $this->assertEquals('string', (string)$reflection->getMethod('list')->getReturnType());
    }

    public function testUnarchiveMethodReturnType(): void
    {
        $reflection = new \ReflectionClass($this->controller);
        $this->assertEquals('void', (string)$reflection->getMethod('unarchive')->getReturnType());
    }

    public function testConstructorRequiresProductRepository(): void
    {
        $reflection = new \ReflectionClass(ProductArchiveController::class);
        $constructor = $reflection->getConstructor();
        $params = $constructor->getParameters();

        $this->assertCount(1, $params);
        $this->assertEquals('Domain\Product\ProductRepository', $params[0]->getType()->getName());
    }
}
