public function testHandle() { $pricing = $this->dummyData->getPricing(); $tagService = $this->mockService->getTagService(); $dtoBuilderFactory = $this->getDTOBuilderFactory(); $request = new GetTagRequest(self::UUID_HEX); $response = new GetTagResponse($pricing); $handler = new GetTagHandler($tagService, $dtoBuilderFactory); $handler->handle(new GetTagQuery($request, $response)); $this->assertTrue($response->getTagDTO() instanceof TagDTO); $handler->handle(new GetTagQuery($request, $response)); $this->assertTrue($response->getTagDTOWithAllData() instanceof TagDTO); }
/** * @param Request $httpRequest * @param string $slug * @param string $tagId * @return \Illuminate\Http\RedirectResponse */ public function show(Request $httpRequest, $slug, $tagId) { $request = new GetTagRequest($tagId); $response = new GetTagResponse($this->getPricing()); $this->dispatchQuery(new GetTagQuery($request, $response)); $tagDTO = $response->getTagDTOWithAllData(); if ($slug !== $tagDTO->slug) { return redirect()->route('tag.show', ['slug' => $tagDTO->slug, 'tagId' => $tagDTO->id->getHex()]); } $request = new GetProductsByTagRequest($tagDTO->id->getHex(), $this->getPaginationDTO(12)); $response = new GetProductsByTagResponse($this->getPricing()); $this->dispatchQuery(new GetProductsByTagQuery($request, $response)); $productDTOs = $response->getProductDTOs(); $paginationDTO = $response->getPaginationDTO(); return $this->renderTemplate('tag/show.twig', ['tag' => $tagDTO, 'products' => $productDTOs, 'pagination' => $paginationDTO]); }
/** * @return TagDTO */ protected function getDummyTag() { $faker = \Faker\Factory::create(); $tagDTO = new TagDTO(); $tagDTO->name = $faker->name; $tagDTO->defaultImage = $faker->imageUrl(); $tagDTO->description = $faker->paragraph(5); $tagDTO->isVisible = true; $tagDTO->isActive = true; $tagDTO->sortOrder = 0; $command = new CreateTagCommand($tagDTO); $this->dispatch($command); $tagId = $command->getTagId()->getHex(); $request = new GetTagRequest($tagId); $response = new GetTagResponse($this->getPricing()); $this->dispatchQuery(new GetTagQuery($request, $response)); return $response->getTagDTO(); }