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

use PHPUnit\Framework\TestCase;
use admin\Controllers\ShopClientsController;
use Domain\Client\ClientRepository;

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

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

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

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

    public function testHasLegacyAliasMethods(): void
    {
        $this->assertTrue(method_exists($this->controller, 'view_list'));
        $this->assertTrue(method_exists($this->controller, 'clients_details'));
    }

    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('string', (string)$reflection->getMethod('details')->getReturnType());
        $this->assertEquals('string', (string)$reflection->getMethod('clients_details')->getReturnType());
    }

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

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