Esempio n. 1
0
 /**
  * @test
  * 
  * @expectedException \Payum\Core\Reply\Base
  */
 public function shouldNotCatchReplyByDefault()
 {
     $firstRequest = new \stdClass();
     $secondRequest = new \stdClass();
     $replyMock = $this->createReplyMock();
     $firstAction = new RequireOtherRequestAction();
     $firstAction->setSupportedRequest($firstRequest);
     $firstAction->setRequiredRequest($secondRequest);
     $secondAction = new ThrowReplyAction();
     $secondAction->setSupportedRequest($secondRequest);
     $secondAction->setReply($replyMock);
     $payment = new Payment();
     $payment->addAction($firstAction);
     $payment->addAction($secondAction);
     $payment->execute($firstRequest);
 }
Esempio n. 2
0
 /**
  * @test
  * 
  * @expectedException \Payum\Core\Request\BaseInteractiveRequest
  */
 public function shouldNotCatchInteractiveRequestByDefault()
 {
     $firstRequest = new \stdClass();
     $secondRequest = new \stdClass();
     $interactiveRequest = $this->createInteractiveRequestMock();
     $firstAction = new RequireOtherRequestAction();
     $firstAction->setSupportedRequest($firstRequest);
     $firstAction->setRequiredRequest($secondRequest);
     $secondAction = new ThrowInteractiveAction();
     $secondAction->setSupportedRequest($secondRequest);
     $secondAction->setInteractiveRequest($interactiveRequest);
     $payment = new Payment();
     $payment->addAction($firstAction);
     $payment->addAction($secondAction);
     $payment->execute($firstRequest);
 }
Esempio n. 3
0
 /**
  * @test
  */
 public function shouldPopulateContextWithPreviousOnesOnSubExecutes()
 {
     $gateway = new Gateway();
     $firstRequest = new \stdClass();
     $secondRequest = new \stdClass();
     $firstAction = new RequireOtherRequestAction();
     $firstAction->setSupportedRequest($firstRequest);
     $firstAction->setRequiredRequest($secondRequest);
     $gateway->addAction($firstAction);
     $actionMock = $this->createActionMock();
     $actionMock->expects($this->any())->method('supports')->willReturnCallback(function ($request) use($secondRequest) {
         return $secondRequest === $request;
     });
     $gateway->addAction($actionMock);
     $testCase = $this;
     $extensionMock = $this->createExtensionMock();
     $extensionMock->expects($this->at(0))->method('onPreExecute')->willReturnCallback(function (Context $context) use($testCase, $firstRequest) {
         $testCase->assertSame($firstRequest, $context->getRequest());
         $testCase->assertEmpty($context->getPrevious());
     });
     $extensionMock->expects($this->at(1))->method('onPreExecute')->willReturnCallback(function (Context $context) use($testCase, $secondRequest) {
         $testCase->assertSame($secondRequest, $context->getRequest());
         $testCase->assertCount(1, $context->getPrevious());
         $this->assertContainsOnly('Payum\\Core\\Extension\\Context', $context->getPrevious());
     });
     $gateway->addExtension($extensionMock);
     $gateway->execute($firstRequest);
 }