/**
  * If the request is to update an existing product
  * the rules should contain a unique constraint excluding
  * the existing product.
  */
 public function testRulesExcludeExistingForUpdateRequest()
 {
     $this->httpRequest->shouldReceive('method')->andReturn($this->generator()->anyOneOf([HttpRequest::METHOD_PUT, HttpRequest::METHOD_PATCH]));
     $ID = $this->generator()->anyInteger();
     $this->httpRequest->shouldReceive('get')->with('id')->andReturn($ID);
     $rules = $this->persistProductRequest->rules($this->httpRequest);
     foreach (['name', 'sku'] as $ruleSetKey) {
         $this->assertContains("unique:products,{$ruleSetKey},{$ID}", explode('|', $rules[$ruleSetKey]));
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param PersistProductRequest $request
  * @param string                $sku
  *
  * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
  * @throws \Illuminate\Database\Eloquent\MassAssignmentException
  *
  * @return \Illuminate\Http\Response|RedirectResponse
  */
 public function update(PersistProductRequest $request, string $sku)
 {
     $product = $this->catalogueRepository->updateProduct($sku, $request->all());
     return $this->redirectToShowProduct($product->sku);
 }