Open Journal Systems  3.3.0
lib/vendor/omnipay/paypal/tests/ExpressInContextGatewayTest.php
1 <?php
2 
3 namespace Omnipay\PayPal;
4 
5 use Omnipay\Tests\GatewayTestCase;
6 
7 class ExpressInContextGatewayTest extends GatewayTestCase
8 {
12  protected $gateway;
13 
17  protected $options;
18 
22  protected $voidOptions;
23 
24  public function setUp()
25  {
26  parent::setUp();
27 
28  $this->gateway = new ExpressInContextGateway($this->getHttpClient(), $this->getHttpRequest());
29 
30  $this->options = array(
31  'amount' => '10.00',
32  'returnUrl' => 'https://www.example.com/return',
33  'cancelUrl' => 'https://www.example.com/cancel',
34  );
35  $this->voidOptions = array(
36  'transactionReference' => 'ASDFASDFASDF',
37  );
38  }
39 
40  public function testAuthorizeSuccess()
41  {
42  $this->setMockHttpResponse('ExpressPurchaseSuccess.txt');
43 
44  $response = $this->gateway->authorize($this->options)->send();
45 
46  $this->assertInstanceOf('\Omnipay\PayPal\Message\ExpressInContextAuthorizeResponse', $response);
47  $this->assertFalse($response->isPending());
48  $this->assertFalse($response->isSuccessful());
49  $this->assertTrue($response->isRedirect());
50  $this->assertEquals('https://www.paypal.com/checkoutnow?useraction=commit&token=EC-42721413K79637829', $response->getRedirectUrl());
51  }
52 
53  public function testPurchaseSuccess()
54  {
55  $this->setMockHttpResponse('ExpressPurchaseSuccess.txt');
56 
57  $response = $this->gateway->purchase($this->options)->send();
58 
59  $this->assertInstanceOf('\Omnipay\PayPal\Message\ExpressInContextAuthorizeResponse', $response);
60  $this->assertFalse($response->isPending());
61  $this->assertFalse($response->isSuccessful());
62  $this->assertTrue($response->isRedirect());
63  $this->assertEquals('https://www.paypal.com/checkoutnow?useraction=commit&token=EC-42721413K79637829', $response->getRedirectUrl());
64  }
65 
66  public function testOrderSuccess()
67  {
68  $this->setMockHttpResponse('ExpressOrderSuccess.txt');
69 
70  $response = $this->gateway->order($this->options)->send();
71 
72  $this->assertInstanceOf('\Omnipay\PayPal\Message\ExpressInContextAuthorizeResponse', $response);
73  $this->assertFalse($response->isPending());
74  $this->assertFalse($response->isSuccessful());
75  $this->assertTrue($response->isRedirect());
76  $this->assertEquals('https://www.paypal.com/checkoutnow?useraction=commit&token=EC-42721413K79637829', $response->getRedirectUrl());
77  }
78 }
Omnipay\PayPal
Definition: lib/vendor/omnipay/paypal/src/ExpressGateway.php:3
Omnipay\PayPal\ExpressInContextGateway
Definition: lib/vendor/omnipay/paypal/src/ExpressInContextGateway.php:8
Omnipay\PayPal\ExpressInContextGatewayTest\$options
$options
Definition: lib/vendor/omnipay/paypal/tests/ExpressInContextGatewayTest.php:23
Omnipay\PayPal\ExpressInContextGatewayTest\setUp
setUp()
Definition: lib/vendor/omnipay/paypal/tests/ExpressInContextGatewayTest.php:33
Omnipay\PayPal\ExpressInContextGatewayTest\testAuthorizeSuccess
testAuthorizeSuccess()
Definition: lib/vendor/omnipay/paypal/tests/ExpressInContextGatewayTest.php:49
Omnipay\PayPal\ExpressInContextGatewayTest
Definition: lib/vendor/omnipay/paypal/tests/ExpressInContextGatewayTest.php:7
Omnipay\PayPal\ExpressInContextGatewayTest\testPurchaseSuccess
testPurchaseSuccess()
Definition: lib/vendor/omnipay/paypal/tests/ExpressInContextGatewayTest.php:62
Omnipay\PayPal\ExpressInContextGatewayTest\$gateway
$gateway
Definition: lib/vendor/omnipay/paypal/tests/ExpressInContextGatewayTest.php:15
Omnipay\PayPal\ExpressInContextGatewayTest\testOrderSuccess
testOrderSuccess()
Definition: lib/vendor/omnipay/paypal/tests/ExpressInContextGatewayTest.php:75
Omnipay\PayPal\ExpressInContextGatewayTest\$voidOptions
$voidOptions
Definition: lib/vendor/omnipay/paypal/tests/ExpressInContextGatewayTest.php:31