Files
shopPRO/tests/Unit/front/Controllers/ShopProducerControllerTest.php

41 lines
1.3 KiB
PHP

<?php
namespace Tests\Unit\front\Controllers;
use PHPUnit\Framework\TestCase;
use front\Controllers\ShopProducerController;
use Domain\Producer\ProducerRepository;
class ShopProducerControllerTest extends TestCase
{
private $repository;
private $controller;
protected function setUp(): void
{
$this->repository = $this->createMock(ProducerRepository::class);
$this->controller = new ShopProducerController($this->repository);
}
public function testConstructorAcceptsRepository(): void
{
$controller = new ShopProducerController($this->repository);
$this->assertInstanceOf(ShopProducerController::class, $controller);
}
public function testHasMainActionMethods(): void
{
$this->assertTrue(method_exists($this->controller, 'products'));
$this->assertTrue(method_exists($this->controller, 'list'));
}
public function testConstructorRequiresProducerRepository(): void
{
$reflection = new \ReflectionClass(ShopProducerController::class);
$constructor = $reflection->getConstructor();
$params = $constructor->getParameters();
$this->assertCount(1, $params);
$this->assertEquals('Domain\Producer\ProducerRepository', $params[0]->getType()->getName());
}
}