public function index(Request $httpRequest) { $queryString = $httpRequest->query('q'); $request = new ListProductsRequest($queryString, $this->getPaginationDTO(20)); $response = new ListProductsResponse(); $this->dispatchQuery(new ListProductsQuery($request, $response)); $products = $response->getProductDTOs(); $pagination = $response->getPaginationDTO(); return $this->renderTemplate('admin/product/index.twig', ['products' => $products, 'pagination' => $pagination, 'queryString' => $queryString]); }
public function testHandle() { $productService = $this->mockService->getProductService(); $dtoBuilderFactory = $this->getDTOBuilderFactory(); $queryString = 'product'; $request = new ListProductsRequest($queryString, new PaginationDTO()); $response = new ListProductsResponse(); $handler = new ListProductsHandler($productService, $dtoBuilderFactory); $handler->handle(new ListProductsQuery($request, $response)); $this->assertTrue($response->getProductDTOs()[0] instanceof ProductDTO); $this->assertTrue($response->getPaginationDTO() instanceof PaginationDTO); }