function it_should_not_charge_if_token_is_not_authorized(ChargeToken $request, APIClient $api, Payment $payment) { $model = new ArrayObject(array('PaymentOrder' => array('Status' => APIClient::STATUS_PROGRESS), 'PaymentOrderId' => 456, 'Amount' => 123, 'Currency' => 'EUR')); $request->getModel()->willReturn($model); $api->PaymentOrderCharge(Argument::any(), Argument::any(), Argument::any())->shouldNotBeCalled(); $payment->execute(Argument::any())->shouldNotBeCalled(); $this->execute($request); }
/** * @test * * @expectedException \Payum\Core\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\Core\Exception\RequestNotSupportedException */ public function shouldCallExtensionOnExceptionWhenExceptionThrown() { $notSupportedRequest = new \stdClass(); $extensionMock = $this->createExtensionMock(); $extensionMock->expects($this->once())->method('onException')->with($this->isInstanceOf('Payum\\Core\\Exception\\RequestNotSupportedException'), $this->identicalTo($notSupportedRequest)); $payment = new Payment(); $payment->addExtension($extensionMock); $payment->execute($notSupportedRequest); }