/**
     * @test
     */
    public function shouldExecuteRefundRequestWithoutAfterUrl()
    {
        $request = Request::create('/');
        $request->query->set('foo', 'fooVal');

        $token = new Token;
        $token->setPaymentName('thePayment');
        $token->setAfterUrl(null);

        $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))
        ;

        $paymentMock = $this->getMock('Payum\Core\PaymentInterface');
        $paymentMock
            ->expects($this->once())
            ->method('execute')
            ->with($this->isInstanceOf('Payum\Core\Request\Refund'))
        ;

        $registryMock = $this->getMock('Payum\Core\Registry\RegistryInterface');
        $registryMock
            ->expects($this->once())
            ->method('getPayment')
            ->with('thePayment')
            ->will($this->returnValue($paymentMock))
        ;

        $container = new Container;
        $container->set('payum', $registryMock);
        $container->set('payum.security.http_request_verifier', $tokenVerifierMock);

        $controller = new RefundController;
        $controller->setContainer($container);

        $response = $controller->doAction($request);

        $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $response);
        $this->assertEquals(204, $response->getStatusCode());
    }
 /**
  * @test
  */
 public function shouldExecuteCaptureRequest()
 {
     $request = Request::create('/');
     $request->query->set('foo', 'fooVal');
     $token = new Token();
     $token->setPaymentName('thePayment');
     $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));
     $paymentMock = $this->getMock('Payum\\Core\\PaymentInterface');
     $paymentMock->expects($this->once())->method('execute')->with($this->isInstanceOf('Payum\\Core\\Request\\SecuredCaptureRequest'));
     $registryMock = $this->getMock('Payum\\Core\\Registry\\RegistryInterface');
     $registryMock->expects($this->once())->method('getPayment')->with('thePayment')->will($this->returnValue($paymentMock));
     $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());
 }
Пример #3
0
    /**
     * @test
     */
    public function shouldNotAddNotifyUrlIfTokenFactoryNotSet()
    {
        $details = new \ArrayObject(array(
        ));

        $captureToken = new Token();
        $captureToken->setPaymentName('thePaymentName');
        $captureToken->setDetails($details);

        $action = new CaptureAction();
        $action->setPayment($this->createPaymentMock());

        $request = new Capture($captureToken);
        $request->setModel($details);

        $action->execute($request);

        $this->assertArrayNotHasKey('PAYMENTREQUEST_0_NOTIFYURL', $details);
    }
Пример #4
0
 /**
  * @test
  */
 public function shouldAllowGetPreviouslySetPaymentName()
 {
     $token = new Token();
     $token->setPaymentName('theName');
     $this->assertSame('theName', $token->getPaymentName());
 }