/** * Should be able to update product data. */ public function testUpdate() { $name = $this->generator()->anyString(); $sku = $this->generator()->anyString(); $product = $this->makeMock(Product::class); $this->productResource->shouldReceive('where->firstOrFail')->atLeast()->once()->andReturn($product); $product->expects($this->atLeastOnce())->method('fill')->with(compact('name', 'sku')); $product->expects($this->atLeastOnce())->method('save'); $this->productRepository->update($sku, compact('name', 'sku')); }
/** * @param string $sku * @param array $productData * * @throws \Illuminate\Database\Eloquent\MassAssignmentException * @throws \Illuminate\Database\Eloquent\ModelNotFoundException * * @return Product */ public function updateProduct(string $sku, array $productData) : Product { return $this->productRepository->update($sku, $productData); }