- ShopProduct factory: full migration (~40 ProductRepository methods, ~30 controller actions) - Dashboard: Domain+DI migration (DashboardRepository + DashboardController) - Update: Domain+DI migration (UpdateRepository + UpdateController, template rewrite) - Renamed admin\Site to admin\App, removed dead fallback routing - Removed all legacy folders: admin/controls, admin/factory, admin/view - Newsletter: switched from admin\factory\Articles to ArticleRepository - 414 tests, 1335 assertions passing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
50 lines
1.7 KiB
PHP
50 lines
1.7 KiB
PHP
<?php
|
|
namespace Tests\Unit\admin\Controllers;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use admin\Controllers\DashboardController;
|
|
use Domain\Dashboard\DashboardRepository;
|
|
use Domain\ShopStatus\ShopStatusRepository;
|
|
|
|
class DashboardControllerTest extends TestCase
|
|
{
|
|
private $repository;
|
|
private $statusesRepository;
|
|
private $controller;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->repository = $this->createMock(DashboardRepository::class);
|
|
$this->statusesRepository = $this->createMock(ShopStatusRepository::class);
|
|
$this->controller = new DashboardController($this->repository, $this->statusesRepository);
|
|
}
|
|
|
|
public function testConstructorAcceptsRepositories(): void
|
|
{
|
|
$controller = new DashboardController($this->repository, $this->statusesRepository);
|
|
$this->assertInstanceOf(DashboardController::class, $controller);
|
|
}
|
|
|
|
public function testHasMainViewMethod(): void
|
|
{
|
|
$this->assertTrue(method_exists($this->controller, 'main_view'));
|
|
}
|
|
|
|
public function testMainViewReturnsString(): void
|
|
{
|
|
$reflection = new \ReflectionClass($this->controller);
|
|
$this->assertEquals('string', (string)$reflection->getMethod('main_view')->getReturnType());
|
|
}
|
|
|
|
public function testConstructorRequiresRepositories(): void
|
|
{
|
|
$reflection = new \ReflectionClass(DashboardController::class);
|
|
$constructor = $reflection->getConstructor();
|
|
$params = $constructor->getParameters();
|
|
|
|
$this->assertCount(2, $params);
|
|
$this->assertEquals('Domain\Dashboard\DashboardRepository', $params[0]->getType()->getName());
|
|
$this->assertEquals('Domain\ShopStatus\ShopStatusRepository', $params[1]->getType()->getName());
|
|
}
|
|
}
|