/**
  * @param Product $product
  * @param Product $productCopy
  */
 protected function cloneChildObjects(Product $product, Product $productCopy)
 {
     foreach ($product->getUnitPrecisions() as $unitPrecision) {
         $productCopy->addUnitPrecision(clone $unitPrecision);
     }
     foreach ($product->getNames() as $name) {
         $productCopy->addName(clone $name);
     }
     foreach ($product->getDescriptions() as $description) {
         $productCopy->addDescription(clone $description);
     }
     if ($imageFile = $product->getImage()) {
         $imageFileCopy = $this->attachmentManager->copyAttachmentFile($imageFile);
         $productCopy->setImage($imageFileCopy);
     }
     $attachments = $this->attachmentProvider->getEntityAttachments($product);
     foreach ($attachments as $attachment) {
         $attachmentCopy = clone $attachment;
         $attachmentFileCopy = $this->attachmentManager->copyAttachmentFile($attachment->getFile());
         $attachmentCopy->setFile($attachmentFileCopy);
         $attachmentCopy->setTarget($productCopy);
         $this->doctrineHelper->getEntityManager($attachmentCopy)->persist($attachmentCopy);
     }
 }
 /**
  * @param array $descriptions
  * @dataProvider getDefaultDescriptionExceptionDataProvider
  *
  * @expectedException \LogicException
  * @expectedExceptionMessage There must be only one default description
  */
 public function testGetDefaultDescriptionException(array $descriptions)
 {
     $product = new Product();
     foreach ($descriptions as $description) {
         $product->addDescription($description);
     }
     $product->getDefaultDescription();
 }