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

use PHPUnit\Framework\TestCase;
use admin\Controllers\ShopStatusesController;
use Domain\ShopStatus\ShopStatusRepository;

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

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

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

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

    public function testHasNoLegacyAliasMethods(): void
    {
        $this->assertFalse(method_exists($this->controller, 'view_list'));
        $this->assertFalse(method_exists($this->controller, 'status_edit'));
        $this->assertFalse(method_exists($this->controller, 'status_save'));
    }

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

        $this->assertEquals('string', (string)$reflection->getMethod('list')->getReturnType());
        $this->assertEquals('string', (string)$reflection->getMethod('edit')->getReturnType());
        $this->assertEquals('void', (string)$reflection->getMethod('save')->getReturnType());
    }

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

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