public function testGetListReturnsTheListOfActiveCheckoutAgreements() { $this->scopeConfigMock->expects($this->once())->method('isSetFlag')->with('checkout/options/enable_agreements', ScopeInterface::SCOPE_STORE, null)->will($this->returnValue(true)); $agreementDataObject = $this->getMock('Magento\\CheckoutAgreements\\Model\\Agreement', [], [], '', false); $storeId = 1; $storeMock = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false); $storeMock->expects($this->any())->method('getId')->will($this->returnValue($storeId)); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); $collectionMock = $this->objectManager->getCollectionMock('Magento\\CheckoutAgreements\\Model\\Resource\\Agreement\\Collection', [$agreementDataObject]); $this->factoryMock->expects($this->once())->method('create')->will($this->returnValue($collectionMock)); $collectionMock->expects($this->once())->method('addStoreFilter')->with($storeId); $collectionMock->expects($this->once())->method('addFieldToFilter')->with('is_active', 1); $this->assertEquals([$agreementDataObject], $this->model->getList()); }
/** * @expectedException \Magento\Framework\Exception\CouldNotDeleteException */ public function testDeleteByIdWithException() { $agreementId = 1; $this->agrFactoryMock->expects($this->once())->method('create')->willReturn($this->agreementMock); $this->resourceMock->expects($this->once())->method('load')->with($this->agreementMock, $agreementId)->willReturn($this->agreementMock); $this->agreementMock->expects($this->once())->method('getId')->willReturn($agreementId); $this->resourceMock->expects($this->once())->method('delete')->willThrowException(new \Exception()); $this->assertTrue($this->model->deleteById(1)); }