/** * @param Product $product * @return Product */ protected function createProductCopy(Product $product) { $productCopy = clone $product; $productCopy->setSku($this->skuIncrementor->increment($product->getSku())); $productCopy->setStatus($this->getDisabledStatus()); $this->cloneChildObjects($product, $productCopy); return $productCopy; }
public function testDuplicateFailed() { $product = (new StubProduct())->setSku(self::PRODUCT_SKU); $this->skuIncrementor->expects($this->once())->method('increment')->with(self::PRODUCT_SKU)->will($this->returnValue(self::PRODUCT_COPY_SKU)); $this->attachmentProvider->expects($this->once())->method('getEntityAttachments')->with($product)->will($this->returnValue([])); $this->connection->expects($this->once())->method('beginTransaction'); $this->connection->expects($this->once())->method('commit')->will($this->throwException(new \Exception())); $this->connection->expects($this->once())->method('rollback'); $this->setExpectedException('Exception'); $this->duplicator->duplicate($product); }