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

use PHPUnit\Framework\TestCase;
use admin\Controllers\ArticlesArchiveController;
use Domain\Article\ArticleRepository;

class ArticlesArchiveControllerTest extends TestCase
{
    private $repository;
    private $controller;

    protected function setUp(): void
    {
        $this->repository = $this->createMock(ArticleRepository::class);
        $this->controller = new ArticlesArchiveController($this->repository);
    }

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

    public function testHasMainActionMethods(): void
    {
        $this->assertTrue(method_exists($this->controller, 'list'));
        $this->assertTrue(method_exists($this->controller, 'view_list'));
        $this->assertTrue(method_exists($this->controller, 'restore'));
        $this->assertTrue(method_exists($this->controller, 'delete'));
    }

    public function testActionMethodReturnTypes(): void
    {
        $reflection = new \ReflectionClass($this->controller);

        $this->assertEquals('string', (string)$reflection->getMethod('list')->getReturnType());
        $this->assertEquals('string', (string)$reflection->getMethod('view_list')->getReturnType());
        $this->assertEquals('void', (string)$reflection->getMethod('restore')->getReturnType());
        $this->assertEquals('void', (string)$reflection->getMethod('delete')->getReturnType());
    }

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

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