ver. 0.277: ShopProduct factory, Dashboard, Update migration, legacy cleanup, admin\App
- 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>
This commit is contained in:
89
tests/Unit/Domain/Dashboard/DashboardRepositoryTest.php
Normal file
89
tests/Unit/Domain/Dashboard/DashboardRepositoryTest.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
namespace Tests\Unit\Domain\Dashboard;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Domain\Dashboard\DashboardRepository;
|
||||
|
||||
class DashboardRepositoryTest extends TestCase
|
||||
{
|
||||
private function createMockDb(): \medoo
|
||||
{
|
||||
return $this->createMock(\medoo::class);
|
||||
}
|
||||
|
||||
public function testConstructorAcceptsDb(): void
|
||||
{
|
||||
$db = $this->createMockDb();
|
||||
$repository = new DashboardRepository($db);
|
||||
$this->assertInstanceOf(DashboardRepository::class, $repository);
|
||||
}
|
||||
|
||||
public function testHasAllPublicMethods(): void
|
||||
{
|
||||
$db = $this->createMockDb();
|
||||
$repository = new DashboardRepository($db);
|
||||
|
||||
$expectedMethods = [
|
||||
'summaryOrders',
|
||||
'summarySales',
|
||||
'salesGrid',
|
||||
'mostViewedProducts',
|
||||
'bestSalesProducts',
|
||||
'last24MonthsSales',
|
||||
'lastOrders',
|
||||
];
|
||||
|
||||
foreach ($expectedMethods as $method) {
|
||||
$this->assertTrue(
|
||||
method_exists($repository, $method),
|
||||
"Missing method: {$method}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSalesGridReturnsArray(): void
|
||||
{
|
||||
$db = $this->createMockDb();
|
||||
$db->method('select')->willReturn([]);
|
||||
$repository = new DashboardRepository($db);
|
||||
|
||||
$result = $repository->salesGrid();
|
||||
$this->assertIsArray($result);
|
||||
}
|
||||
|
||||
public function testLastOrdersReturnsArray(): void
|
||||
{
|
||||
$db = $this->createMockDb();
|
||||
$stmt = $this->createMock(\PDOStatement::class);
|
||||
$stmt->method('fetchAll')->willReturn([]);
|
||||
$db->method('query')->willReturn($stmt);
|
||||
|
||||
$repository = new DashboardRepository($db);
|
||||
$result = $repository->lastOrders();
|
||||
$this->assertIsArray($result);
|
||||
}
|
||||
|
||||
public function testMostViewedProductsReturnsArray(): void
|
||||
{
|
||||
$db = $this->createMockDb();
|
||||
$stmt = $this->createMock(\PDOStatement::class);
|
||||
$stmt->method('fetchAll')->willReturn([]);
|
||||
$db->method('query')->willReturn($stmt);
|
||||
|
||||
$repository = new DashboardRepository($db);
|
||||
$result = $repository->mostViewedProducts();
|
||||
$this->assertIsArray($result);
|
||||
}
|
||||
|
||||
public function testBestSalesProductsReturnsArray(): void
|
||||
{
|
||||
$db = $this->createMockDb();
|
||||
$stmt = $this->createMock(\PDOStatement::class);
|
||||
$stmt->method('fetchAll')->willReturn([]);
|
||||
$db->method('query')->willReturn($stmt);
|
||||
|
||||
$repository = new DashboardRepository($db);
|
||||
$result = $repository->bestSalesProducts();
|
||||
$this->assertIsArray($result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user