/** * @test * @dataProvider paymentActionEnabledForCustomPaymentMethodDataProvider * @return void */ public function paymentActionEnabledForCustomPaymentMethodReturnsExpectedResult($action, $expected) { $mockPaymentInstance = $this->getAccessibleMock('DERHANSEN\\SfEventMgt\\Payment\\Invoice', ['isRedirectEnabled', 'isSuccessLinkEnabled', 'isFailureLinkEnabled', 'isCancelLinkEnabled', 'isNotifyLinkEnabled'], [], '', false); $mockPaymentInstance->expects($this->any())->method('isRedirectEnabled')->will($this->returnValue(true)); $mockPaymentInstance->expects($this->any())->method('isSuccessLinkEnabled')->will($this->returnValue(true)); $mockPaymentInstance->expects($this->any())->method('isFailureLinkEnabled')->will($this->returnValue(true)); $mockPaymentInstance->expects($this->any())->method('isCancelLinkEnabled')->will($this->returnValue(true)); $mockPaymentInstance->expects($this->any())->method('isNotifyLinkEnabled')->will($this->returnValue(true)); $this->subject = $this->getAccessibleMock('DERHANSEN\\SfEventMgt\\Service\\PaymentService', ['getPaymentInstance'], [], '', false); $this->subject->expects($this->once())->method('getPaymentInstance')->will($this->returnValue($mockPaymentInstance)); $this->assertEquals($expected, $this->subject->paymentActionEnabled('invoice', $action)); }
/** * Checks if the given action can be called for the given registration / event and throws * an exception if action should not proceed * * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration * @param string $actionName * @throws PaymentException * @return void */ protected function proceedWithAction($registration, $actionName) { if ($registration->getEvent()->getEnablePayment() === false) { $message = LocalizationUtility::translate('payment.messages.paymentNotEnabled', 'sf_event_mgt'); throw new PaymentException($message, 1899934881); } if ($this->paymentService->paymentActionEnabled($registration->getPaymentmethod(), $actionName) === false) { $message = LocalizationUtility::translate('payment.messages.actionNotEnabled', 'sf_event_mgt'); throw new PaymentException($message, 1899934882); } if ($registration->getPaid()) { $message = LocalizationUtility::translate('payment.messages.paymentAlreadyProcessed', 'sf_event_mgt'); throw new PaymentException($message, 1899934883); } if ($registration->getEvent()->getRestrictPaymentMethods()) { $selectedPaymentMethods = explode(',', $registration->getEvent()->getSelectedPaymentMethods()); if (!in_array($registration->getPaymentmethod(), $selectedPaymentMethods)) { $message = LocalizationUtility::translate('payment.messages.paymentMethodNotAvailable', 'sf_event_mgt'); throw new PaymentException($message, 1899934884); } } }