/** * @expectedException \Exception * @expectedExceptionMessage To test exception */ public function testDeletionRollbackOnFailure() { $expectedException = new \Exception(__('To test exception')); $this->transactionManagerMock->expects($this->once())->method('start'); $abstractModelMock = $this->getMockBuilder('Magento\\Rule\\Model\\AbstractModel')->disableOriginalConstructor()->setMethods([])->getMock(); $abstractModelMock->expects($this->once())->method('beforeDelete')->willThrowException($expectedException); $this->transactionManagerMock->expects($this->once())->method('rollBack'); $this->model->delete($abstractModelMock); }
/** * {@inheritdoc} */ public function delete(\Magento\Framework\Model\AbstractModel $object) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'delete'); if (!$pluginInfo) { return parent::delete($object); } else { return $this->___callPlugins('delete', func_get_args(), $pluginInfo); } }
public function testDelete() { $this->entityManager->expects($this->once())->method('delete')->with($this->rule); $this->assertEquals($this->model->delete($this->rule), $this->model); }