Files
shopPRO/tests/Unit/admin/Controllers/ShopProducerControllerTest.php
Jacek Pyziak 3bac7616e7 ver. 0.273 - ShopProducer refactor + cleanup 6 factory facades
- Domain\Producer\ProducerRepository (CRUD + frontend)
- admin\Controllers\ShopProducerController (DI)
- Nowe widoki: producers-list, producer-edit (table-list/form-edit)
- shop\Producer -> fasada do ProducerRepository
- Przepiecie ShopProduct factory na TransportRepository
- Usuniete 6 pustych factory facades: Languages, Newsletter, Scontainers, ShopProducer, ShopTransport, Layouts
- Usuniete legacy: controls\ShopProducer, stare szablony
- Testy: 338 tests, 1063 assertions OK
2026-02-15 10:46:55 +01:00

68 lines
2.9 KiB
PHP

<?php
namespace Tests\Unit\admin\Controllers;
use PHPUnit\Framework\TestCase;
use admin\Controllers\ShopProducerController;
use Domain\Producer\ProducerRepository;
use Domain\Languages\LanguagesRepository;
class ShopProducerControllerTest extends TestCase
{
private $repository;
private $languagesRepository;
private $controller;
protected function setUp(): void
{
$this->repository = $this->createMock(ProducerRepository::class);
$this->languagesRepository = $this->createMock(LanguagesRepository::class);
$this->controller = new ShopProducerController($this->repository, $this->languagesRepository);
}
public function testConstructorAcceptsRepositories(): void
{
$controller = new ShopProducerController($this->repository, $this->languagesRepository);
$this->assertInstanceOf(ShopProducerController::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'));
$this->assertTrue(method_exists($this->controller, 'delete'));
}
public function testHasLegacyAliasMethods(): void
{
$this->assertTrue(method_exists($this->controller, 'view_list'));
$this->assertTrue(method_exists($this->controller, 'producer_edit'));
$this->assertTrue(method_exists($this->controller, 'producer_save'));
$this->assertTrue(method_exists($this->controller, 'producer_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('string', (string)$reflection->getMethod('edit')->getReturnType());
$this->assertEquals('string', (string)$reflection->getMethod('producer_edit')->getReturnType());
$this->assertEquals('void', (string)$reflection->getMethod('save')->getReturnType());
$this->assertEquals('void', (string)$reflection->getMethod('delete')->getReturnType());
$this->assertEquals('void', (string)$reflection->getMethod('producer_delete')->getReturnType());
}
public function testConstructorRequiresBothRepositories(): void
{
$reflection = new \ReflectionClass(ShopProducerController::class);
$constructor = $reflection->getConstructor();
$params = $constructor->getParameters();
$this->assertCount(2, $params);
$this->assertEquals('Domain\Producer\ProducerRepository', $params[0]->getType()->getName());
$this->assertEquals('Domain\Languages\LanguagesRepository', $params[1]->getType()->getName());
}
}