ver. 0.272 - ShopProductSets refactor + update package

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 10:21:29 +01:00
parent 67b0a2bb6a
commit ca445d40d9
23 changed files with 993 additions and 297 deletions

View File

@@ -0,0 +1,62 @@
<?php
namespace Tests\Unit\admin\Controllers;
use PHPUnit\Framework\TestCase;
use admin\Controllers\ShopProductSetsController;
use Domain\ProductSet\ProductSetRepository;
class ShopProductSetsControllerTest extends TestCase
{
private $repository;
private $controller;
protected function setUp(): void
{
$this->repository = $this->createMock(ProductSetRepository::class);
$this->controller = new ShopProductSetsController($this->repository);
}
public function testConstructorAcceptsRepository(): void
{
$controller = new ShopProductSetsController($this->repository);
$this->assertInstanceOf(ShopProductSetsController::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, 'set_edit'));
$this->assertTrue(method_exists($this->controller, 'set_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('set_edit')->getReturnType());
$this->assertEquals('void', (string)$reflection->getMethod('save')->getReturnType());
$this->assertEquals('void', (string)$reflection->getMethod('delete')->getReturnType());
$this->assertEquals('void', (string)$reflection->getMethod('set_delete')->getReturnType());
}
public function testConstructorRequiresProductSetRepository(): void
{
$reflection = new \ReflectionClass(ShopProductSetsController::class);
$constructor = $reflection->getConstructor();
$params = $constructor->getParameters();
$this->assertCount(1, $params);
$this->assertEquals('Domain\ProductSet\ProductSetRepository', $params[0]->getType()->getName());
}
}