Files
shopPRO/tests/Unit/admin/Controllers/ProductArchiveControllerTest.php
Jacek Pyziak 0a14c92109 feat: bulk delete in product archive (v0.327)
- Add bulk_delete_permanent() endpoint (POST ids[], returns JSON)
- Checkbox column + bulk action bar with count label
- Select-all in table header, confirmation dialog before delete
- 2 new tests for bulk_delete_permanent method signature

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 20:37:22 +01:00

68 lines
2.2 KiB
PHP

<?php
namespace Tests\Unit\admin\Controllers;
use PHPUnit\Framework\TestCase;
use admin\Controllers\ProductArchiveController;
use Domain\Product\ProductRepository;
class ProductArchiveControllerTest extends TestCase
{
private $mockRepository;
private $controller;
protected function setUp(): void
{
$this->mockRepository = $this->createMock(ProductRepository::class);
$this->controller = new ProductArchiveController($this->mockRepository);
}
public function testConstructorAcceptsRepository(): void
{
$controller = new ProductArchiveController($this->mockRepository);
$this->assertInstanceOf(ProductArchiveController::class, $controller);
}
public function testHasListMethod(): void
{
$this->assertTrue(method_exists($this->controller, 'list'));
}
public function testHasUnarchiveMethod(): void
{
$this->assertTrue(method_exists($this->controller, 'unarchive'));
}
public function testListMethodReturnType(): void
{
$reflection = new \ReflectionClass($this->controller);
$this->assertEquals('string', (string)$reflection->getMethod('list')->getReturnType());
}
public function testUnarchiveMethodReturnType(): void
{
$reflection = new \ReflectionClass($this->controller);
$this->assertEquals('void', (string)$reflection->getMethod('unarchive')->getReturnType());
}
public function testConstructorRequiresProductRepository(): void
{
$reflection = new \ReflectionClass(ProductArchiveController::class);
$constructor = $reflection->getConstructor();
$params = $constructor->getParameters();
$this->assertCount(1, $params);
$this->assertEquals('Domain\Product\ProductRepository', $params[0]->getType()->getName());
}
public function testHasBulkDeletePermanentMethod(): void
{
$this->assertTrue(method_exists($this->controller, 'bulk_delete_permanent'));
}
public function testBulkDeletePermanentMethodReturnType(): void
{
$reflection = new \ReflectionClass($this->controller);
$this->assertEquals('void', (string)$reflection->getMethod('bulk_delete_permanent')->getReturnType());
}
}