|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Omnipay\PayPal; |
| 4 | + |
| 5 | +use Omnipay\Tests\GatewayTestCase; |
| 6 | + |
| 7 | +class ExpressInContextGatewayTest extends GatewayTestCase |
| 8 | +{ |
| 9 | + /** |
| 10 | + * @var \Omnipay\PayPal\ExpressInContextGateway |
| 11 | + */ |
| 12 | + protected $gateway; |
| 13 | + |
| 14 | + /** |
| 15 | + * @var array |
| 16 | + */ |
| 17 | + protected $options; |
| 18 | + |
| 19 | + /** |
| 20 | + * @var array |
| 21 | + */ |
| 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 | +} |
0 commit comments