- Migrate ShopStatuses module to Domain + DI architecture - Add ShopStatusRepository, ShopStatusesController with color picker - Convert front\factory\ShopStatuses to facade - Add FormFieldType::COLOR with HTML5 color picker - Move documentation files to docs/ folder (PROJECT_STRUCTURE, REFACTORING_PLAN, CHANGELOG, FORM_EDIT_SYSTEM, TESTING, DATABASE_STRUCTURE) - Tests: 254 tests, 736 assertions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
58 lines
2.0 KiB
PHP
58 lines
2.0 KiB
PHP
<?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());
|
|
}
|
|
}
|