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

use PHPUnit\Framework\TestCase;
use front\Controllers\ShopBasketController;
use Domain\Order\OrderRepository;
use Domain\PaymentMethod\PaymentMethodRepository;

class ShopBasketControllerTest extends TestCase
{
    private $orderRepository;
    private $paymentMethodRepository;
    private $controller;

    protected function setUp(): void
    {
        $this->orderRepository = $this->createMock(OrderRepository::class);
        $this->paymentMethodRepository = $this->createMock(PaymentMethodRepository::class);
        $this->controller = new ShopBasketController($this->orderRepository, $this->paymentMethodRepository);
    }

    public function testConstructorAcceptsRepositories(): void
    {
        $controller = new ShopBasketController($this->orderRepository, $this->paymentMethodRepository);
        $this->assertInstanceOf(ShopBasketController::class, $controller);
    }

    public function testHasCheckoutMethods(): void
    {
        $this->assertTrue(method_exists($this->controller, 'summaryView'));
        $this->assertTrue(method_exists($this->controller, 'basketSave'));
    }

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

        $this->assertCount(2, $params);
        $this->assertEquals('Domain\Order\OrderRepository', $params[0]->getType()->getName());
        $this->assertEquals('Domain\PaymentMethod\PaymentMethodRepository', $params[1]->getType()->getName());
    }
}
