public function testGetScopeEntityAttachments()
 {
     $entity = $this->getMock('\\stdClass');
     $oroAttachments = [];
     $size = 3;
     for ($i = 0; $i < $size; $i++) {
         $oroAttachments[] = $this->getMock('Oro\\Bundle\\AttachmentBundle\\Entity\\Attachment');
     }
     $this->attachmentProvider->expects($this->once())->method('getEntityAttachments')->with($entity)->willReturn($oroAttachments);
     $this->emailAttachmentTransformer->expects($this->exactly($size))->method('oroToModel');
     $result = $this->emailAttachmentProvider->getScopeEntityAttachments($entity);
     $this->assertTrue(is_array($result));
     $this->assertEquals($size, sizeof($result));
 }
 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);
 }