public function testDuplicate()
 {
     $image = new File();
     $imageCopy = new File();
     $attachmentFile1 = new File();
     $attachmentFileCopy1 = new File();
     $attachmentFile2 = new File();
     $attachmentFileCopy2 = new File();
     $attachment1 = (new Attachment())->setFile($attachmentFile1);
     $attachment2 = (new Attachment())->setFile($attachmentFile2);
     $product = (new StubProduct())->setSku(self::PRODUCT_SKU)->addUnitPrecision($this->prepareUnitPrecision(self::UNIT_PRECISION_CODE_1, self::UNIT_PRECISION_DEFAULT_PRECISION_1))->addUnitPrecision($this->prepareUnitPrecision(self::UNIT_PRECISION_CODE_2, self::UNIT_PRECISION_DEFAULT_PRECISION_2))->setImage($image);
     $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([$attachment1, $attachment2]));
     $this->attachmentManager->expects($this->any())->method('copyAttachmentFile')->with($image)->will($this->returnValue($imageCopy));
     $this->attachmentManager->expects($this->any())->method('copyAttachmentFile')->with($attachmentFile1)->will($this->returnValue($attachmentFileCopy1));
     $this->attachmentManager->expects($this->any())->method('copyAttachmentFile')->with($attachmentFile2)->will($this->returnValue($attachmentFileCopy2));
     $this->connection->expects($this->once())->method('beginTransaction');
     $this->connection->expects($this->once())->method('commit');
     $productCopy = $this->duplicator->duplicate($product);
     $productCopyUnitPrecisions = $productCopy->getUnitPrecisions();
     $this->assertEquals(self::PRODUCT_COPY_SKU, $productCopy->getSku());
     $this->assertEquals($this->productStatusDisabled, $productCopy->getStatus());
     $this->assertCount(2, $productCopyUnitPrecisions);
     $this->assertEquals(self::UNIT_PRECISION_CODE_1, $productCopyUnitPrecisions[0]->getUnit()->getCode());
     $this->assertEquals(self::UNIT_PRECISION_DEFAULT_PRECISION_1, $productCopyUnitPrecisions[0]->getUnit()->getDefaultPrecision());
     $this->assertEquals(self::UNIT_PRECISION_CODE_2, $productCopyUnitPrecisions[1]->getUnit()->getCode());
     $this->assertEquals(self::UNIT_PRECISION_DEFAULT_PRECISION_2, $productCopyUnitPrecisions[1]->getUnit()->getDefaultPrecision());
     $this->assertEquals($imageCopy, $productCopy->getImage());
 }