Exemple #1
0
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage test exception
  * @return void
  */
 public function testBeforeDelete()
 {
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->getMock('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface'));
     $this->transactionManagerMock->expects($this->once())->method('start')->with($this->getMock('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface'))->willReturn($this->getMock('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface'));
     $this->objectMock->expects($this->once())->method('getEntityTypeId')->willReturn(665);
     $this->eavConfigMock->expects($this->once())->method('getEntityType')->with(665)->willReturn($this->typeMock);
     $this->typeMock->expects($this->once())->method('getDefaultAttributeSetId')->willReturn(4);
     $this->objectMock->expects($this->once())->method('getAttributeSetId')->willReturn(5);
     $this->relationProcessor->expects($this->once())->method('delete')->willThrowException(new \Exception('test exception'));
     $this->model->delete($this->objectMock);
 }
 /**
  * {@inheritdoc}
  */
 public function delete(AttributeSetInterface $attributeSet)
 {
     try {
         $this->attributeSetResource->delete($attributeSet);
     } catch (\Magento\Framework\Exception\StateException $exception) {
         throw new CouldNotDeleteException(__('Default attribute set can not be deleted'));
     } catch (\Exception $exception) {
         throw new CouldNotDeleteException(__('There was an error deleting attribute set.'));
     }
     return true;
 }