public function testHandle() { $pricing = $this->dummyData->getPricing(); $productService = $this->mockService->getProductService(); $dtoBuilderFactory = $this->getDTOBuilderFactory(); $limit = 4; $productIds = [self::UUID_HEX]; $request = new GetRelatedProductsRequest($productIds, $limit); $response = new GetRelatedProductsResponse($pricing); $handler = new GetRelatedProductsHandler($productService, $dtoBuilderFactory); $handler->handle(new GetRelatedProductsQuery($request, $response)); $this->assertTrue($response->getProductDTOs()[0] instanceof ProductDTO); }
/** * @param string[] $productIds * @param int $limit * @return ProductDTO[] */ protected function getRecommendedProducts($productIds, $limit) { // Hot-wire random for now, until tags get into the db return $this->getRandomProducts($limit); $request = new GetRelatedProductsRequest($productIds, $limit); $response = new GetRelatedProductsResponse($this->getPricing()); $this->dispatchQuery(new GetRelatedProductsQuery($request, $response)); return $response->getProductDTOs(); }