Release 0.265: ShopPromotion date_from and edit save fix

This commit is contained in:
2026-02-13 22:44:07 +01:00
parent d824ba3909
commit 88e5673569
24 changed files with 1334 additions and 436 deletions

View File

@@ -0,0 +1,53 @@
<?php
namespace Tests\Unit\admin\Controllers;
use PHPUnit\Framework\TestCase;
use admin\Controllers\ShopPromotionController;
use Domain\Promotion\PromotionRepository;
class ShopPromotionControllerTest extends TestCase
{
private $repository;
private $controller;
protected function setUp(): void
{
$this->repository = $this->createMock(PromotionRepository::class);
$this->controller = new ShopPromotionController($this->repository);
}
public function testConstructorAcceptsRepository(): void
{
$controller = new ShopPromotionController($this->repository);
$this->assertInstanceOf(ShopPromotionController::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 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());
$this->assertEquals('void', (string)$reflection->getMethod('delete')->getReturnType());
}
public function testConstructorRequiresPromotionRepository(): void
{
$reflection = new \ReflectionClass(ShopPromotionController::class);
$constructor = $reflection->getConstructor();
$params = $constructor->getParameters();
$this->assertCount(1, $params);
$this->assertEquals('Domain\Promotion\PromotionRepository', $params[0]->getType()->getName());
}
}