/**
  * Should be able to delete a tag.
  */
 public function testDestroy()
 {
     $tagId = $this->generator()->anyInteger();
     $this->tagRepository->expects($this->atLeastOnce())->method('deleteById')->with($tagId);
     $this->responseFactoryWillMakeRedirect();
     $this->tagController->destroy($tagId);
 }
 /**
  * Should be able to get a view response for a product.
  */
 public function testViewAction()
 {
     $tag = new Tag();
     $tag->id = $this->generator()->anyInteger();
     $tag->name = $this->generator()->anyString();
     $this->tagRepository->expects($this->atLeastOnce())->method('loadById')->with($tag->id)->willReturn($tag);
     $this->tagController->viewAction($tag->id, $tag->name);
 }
Example #3
0
 /**
  * @param int    $tagId
  * @param string $tagName
  *
  * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
  *
  * @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
  */
 public function viewAction(int $tagId, string $tagName)
 {
     $tag = $this->tagRepository->loadById($tagId);
     if ($tag->name !== $tagName) {
         return $this->responseFactory->redirectToRoute('tag.view', ['id' => $tag->id, $tag->name]);
     }
     return $this->viewFactory->make('customer.tag.view', compact('tag'));
 }
 /**
  * Should be able to set the tag ids for a product.
  */
 public function testSyncProductTagIds()
 {
     /** @var Product|MockObject $product */
     $product = $this->makeMock(Product::class);
     $tagsRelation = $this->makeMock(BelongsToMany::class);
     $product->expects($this->atLeastOnce())->method('tags')->willReturn($tagsRelation);
     $tagIds = [1, 2, 3];
     $tagsRelation->expects($this->atLeastOnce())->method('sync')->with($tagIds);
     $this->tagRepository->syncProductTagIds($product, $tagIds);
 }
Example #5
0
 /**
  * @param Request $request
  * @param string  $sku
  *
  * @throws NotFoundException
  *
  * @return RedirectResponse
  */
 public function putProductTags(Request $request, string $sku)
 {
     $product = $this->productRepository->loadBySku($sku);
     $tagIds = (array) $request->get('tag-ids');
     $this->tagRepository->syncProductTagIds($product, $tagIds);
     $this->webUi->successMessage("Tags updated for `{$product->sku}`");
     return $this->webUi->redirect('products.show', [$product->sku]);
 }
 /**
  * @return Tag
  */
 public function tag() : Tag
 {
     return $this->tagRepository->resource();
 }