コード例 #1
0
 /**
  * @test
  */
 public function shouldExecuteCaptureRequest()
 {
     $request = Request::create('/');
     $request->query->set('foo', 'fooVal');
     $token = new Token();
     $token->setGatewayName('theGateway');
     $token->setAfterUrl('http://example.com/theAfterUrl');
     $tokenVerifierMock = $this->getMock('Payum\\Core\\Security\\HttpRequestVerifierInterface');
     $tokenVerifierMock->expects($this->once())->method('verify')->with($this->identicalTo($request))->will($this->returnValue($token));
     $tokenVerifierMock->expects($this->once())->method('invalidate')->with($this->identicalTo($token));
     $gatewayMock = $this->getMock('Payum\\Core\\GatewayInterface');
     $gatewayMock->expects($this->once())->method('execute')->with($this->isInstanceOf('Payum\\Core\\Request\\Capture'));
     $registryMock = $this->getMock('Payum\\Core\\Registry\\RegistryInterface');
     $registryMock->expects($this->once())->method('getGateway')->with('theGateway')->will($this->returnValue($gatewayMock));
     $container = new Container();
     $container->set('payum', $registryMock);
     $container->set('payum.security.http_request_verifier', $tokenVerifierMock);
     $controller = new CaptureController();
     $controller->setContainer($container);
     $response = $controller->doAction($request);
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $response);
     $this->assertEquals('http://example.com/theAfterUrl', $response->getTargetUrl());
 }
コード例 #2
0
 /**
  * @test
  */
 public function shouldExecuteCaptureRequest()
 {
     $request = Request::create('/');
     $request->query->set('foo', 'fooVal');
     $token = new Token();
     $token->setGatewayName('theGateway');
     $token->setAfterUrl('http://example.com/theAfterUrl');
     $httpRequestVerifierMock = $this->getMock(HttpRequestVerifierInterface::class);
     $httpRequestVerifierMock->expects($this->once())->method('verify')->with($this->identicalTo($request))->will($this->returnValue($token));
     $httpRequestVerifierMock->expects($this->once())->method('invalidate')->with($this->identicalTo($token));
     $gatewayMock = $this->getMock(GatewayInterface::class);
     $gatewayMock->expects($this->once())->method('execute')->with($this->isInstanceOf(Capture::class));
     $registryMock = $this->getMock(RegistryInterface::class);
     $registryMock->expects($this->once())->method('getGateway')->with('theGateway')->will($this->returnValue($gatewayMock));
     $payum = new Payum($registryMock, $httpRequestVerifierMock, $this->getMock(GenericTokenFactoryInterface::class), $this->getMock(StorageInterface::class));
     $container = new Container();
     $container->set('payum', $payum);
     $controller = new CaptureController();
     $controller->setContainer($container);
     $response = $controller->doAction($request);
     $this->assertInstanceOf(RedirectResponse::class, $response);
     $this->assertEquals('http://example.com/theAfterUrl', $response->getTargetUrl());
 }