/** * @test * * @expectedException \Payum\Exception\LogicException * @expectedExceptionMessage Possible endless cycle detected. ::onPreExecute was called 10 times before reach the limit. */ public function throwCycleRequestIfActionCallsMoreThenLimitAllows() { $cycledRequest = new \stdClass(); $action = new RequireOtherRequestAction(); $action->setSupportedRequest($cycledRequest); $action->setRequiredRequest($cycledRequest); $payment = new Payment(); $payment->addExtension(new EndlessCycleDetectorExtension($limit = 10)); $payment->addAction($action); $payment->execute($cycledRequest); }
/** * @test * * @expectedException \Payum\Exception\RequestNotSupportedException */ public function shouldCallExtensionOnExceptionWhenExceptionThrown() { $notSupportedRequest = new \stdClass(); $extensionMock = $this->createExtensionMock(); $extensionMock->expects($this->once())->method('onException')->with($this->isInstanceOf('Payum\\Exception\\RequestNotSupportedException'), $this->identicalTo($notSupportedRequest)); $payment = new Payment(); $payment->addExtension($extensionMock); $payment->execute($notSupportedRequest); }
/** * @test */ public function logExecutedActions() { $logger = $this->getMock('Psr\\Log\\LoggerInterface'); $logger->expects($this->at(0))->method('debug')->with($this->stringStartsWith('[Payum] 1# ' . get_class(new CaptureAction()) . '::execute(CaptureRequest{model: stdClass})')); //@testo:start //@testo:source //@testo:uncomment:use Payum\Bridge\Psr\Log\LogExecutedActionsExtension; //@testo:uncomment:use Payum\Examples\Action\CaptureAction; //@testo:uncomment:use Payum\Payment; //@testo:uncomment:use Payum\Request\CaptureRequest; $payment = new Payment(); $payment->addExtension(new LogExecutedActionsExtension($logger)); $payment->addAction(new CaptureAction()); $payment->execute(new CaptureRequest($model = new \stdClass())); //@testo:end }