Open Journal Systems  3.3.0
vendor/omnipay/paypal/tests/Message/ExpressInContextAuthorizeResponseTest.php
1 <?php
2 
3 namespace Omnipay\PayPal\Message;
4 
5 use Omnipay\Tests\TestCase;
7 
8 class ExpressInContextAuthorizeResponseTest extends TestCase
9 {
10  public function testConstruct()
11  {
12  // response should decode URL format data
13  $response = new ExpressInContextAuthorizeResponse($this->getMockRequest(), 'example=value&foo=bar');
14 
15  $this->assertEquals(array('example' => 'value', 'foo' => 'bar'), $response->getData());
16  }
17 
18  public function testExpressPurchaseSuccess()
19  {
20  $httpResponse = $this->getMockHttpResponse('ExpressPurchaseSuccess.txt');
21  $request = $this->getMockRequest();
22  $request->shouldReceive('getTestMode')->once()->andReturn(true);
23  $response = new ExpressInContextAuthorizeResponse($request, $httpResponse->getBody());
24 
25  $this->assertFalse($response->isPending());
26  $this->assertFalse($response->isSuccessful());
27  $this->assertSame('EC-42721413K79637829', $response->getTransactionReference());
28  $this->assertNull($response->getMessage());
29  $this->assertNull($response->getRedirectData());
30  $this->assertSame('https://www.sandbox.paypal.com/checkoutnow?useraction=commit&token=EC-42721413K79637829', $response->getRedirectUrl());
31  $this->assertSame('GET', $response->getRedirectMethod());
32  }
33 
34  public function testExpressPurchaseFailure()
35  {
36  $httpResponse = $this->getMockHttpResponse('ExpressPurchaseFailure.txt');
37  $response = new ExpressInContextAuthorizeResponse($this->getMockRequest(), $httpResponse->getBody());
38 
39  $this->assertFalse($response->isPending());
40  $this->assertFalse($response->isSuccessful());
41  $this->assertNull($response->getTransactionReference());
42  $this->assertNull($response->getTransactionReference());
43  $this->assertSame('This transaction cannot be processed. The amount to be charged is zero.', $response->getMessage());
44  }
45 }
Omnipay\PayPal\Message\ExpressInContextAuthorizeResponseTest\testConstruct
testConstruct()
Definition: vendor/omnipay/paypal/tests/Message/ExpressInContextAuthorizeResponseTest.php:10
Omnipay\PayPal\Message\ExpressInContextAuthorizeResponseTest\testExpressPurchaseSuccess
testExpressPurchaseSuccess()
Definition: vendor/omnipay/paypal/tests/Message/ExpressInContextAuthorizeResponseTest.php:18
Omnipay\PayPal\Message\ExpressInContextAuthorizeResponse
Definition: lib/vendor/omnipay/paypal/src/Message/ExpressInContextAuthorizeResponse.php:8
Omnipay\PayPal\Message
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:6
Omnipay\PayPal\Message\ExpressInContextAuthorizeResponseTest\testExpressPurchaseFailure
testExpressPurchaseFailure()
Definition: vendor/omnipay/paypal/tests/Message/ExpressInContextAuthorizeResponseTest.php:34