- Introduced Domain\Article\ArticleRepository for better data access. - Migrated article_edit functionality to admin\Controllers\ArticlesController. - Updated admin\factory\Articles::article_details() to use the new repository. - Marked legacy methods in admin\controls as @deprecated for clarity. - Updated changelog and versioning to reflect changes in version 0.242.
62 lines
1.9 KiB
PHP
62 lines
1.9 KiB
PHP
<?php
|
|
namespace Tests\Unit\admin\Controllers;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use admin\Controllers\ArticlesController;
|
|
use Domain\Article\ArticleRepository;
|
|
|
|
class ArticlesControllerTest extends TestCase
|
|
{
|
|
private $mockRepository;
|
|
private $controller;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->mockRepository = $this->createMock(ArticleRepository::class);
|
|
$this->controller = new ArticlesController($this->mockRepository);
|
|
}
|
|
|
|
public function testCanCreateController(): void
|
|
{
|
|
$this->assertInstanceOf(ArticlesController::class, $this->controller);
|
|
}
|
|
|
|
public function testConstructorAcceptsRepository(): void
|
|
{
|
|
$controller = new ArticlesController($this->mockRepository);
|
|
$this->assertInstanceOf(ArticlesController::class, $controller);
|
|
}
|
|
|
|
public function testHasListMethod(): void
|
|
{
|
|
$this->assertTrue(method_exists($this->controller, 'list'));
|
|
}
|
|
|
|
public function testHasEditMethod(): void
|
|
{
|
|
$this->assertTrue(method_exists($this->controller, 'edit'));
|
|
}
|
|
|
|
public function testListMethodReturnType(): void
|
|
{
|
|
$reflection = new \ReflectionClass($this->controller);
|
|
$this->assertEquals('string', (string)$reflection->getMethod('list')->getReturnType());
|
|
}
|
|
|
|
public function testEditMethodReturnType(): void
|
|
{
|
|
$reflection = new \ReflectionClass($this->controller);
|
|
$this->assertEquals('string', (string)$reflection->getMethod('edit')->getReturnType());
|
|
}
|
|
|
|
public function testConstructorRequiresArticleRepository(): void
|
|
{
|
|
$reflection = new \ReflectionClass(ArticlesController::class);
|
|
$constructor = $reflection->getConstructor();
|
|
$params = $constructor->getParameters();
|
|
|
|
$this->assertCount(1, $params);
|
|
$this->assertEquals('Domain\Article\ArticleRepository', $params[0]->getType()->getName());
|
|
}
|
|
}
|