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); } }