Open Journal Systems  3.3.0
vendor/omnipay/paypal/tests/Message/ResponseTest.php
1 <?php
2 
3 namespace Omnipay\PayPal\Message;
4 
5 use Omnipay\Tests\TestCase;
6 
7 class ResponseTest extends TestCase
8 {
9  public function testConstruct()
10  {
11  // response should decode URL format data
12  $response = new Response($this->getMockRequest(), 'example=value&foo=bar');
13  $this->assertEquals(array('example' => 'value', 'foo' => 'bar'), $response->getData());
14  }
15 
16  public function testProPurchaseSuccess()
17  {
18  $httpResponse = $this->getMockHttpResponse('ProPurchaseSuccess.txt');
19  $response = new Response($this->getMockRequest(), $httpResponse->getBody());
20 
21  $this->assertFalse($response->isPending());
22  $this->assertTrue($response->isSuccessful());
23  $this->assertSame('96U93778BD657313D', $response->getTransactionReference());
24  $this->assertNull($response->getMessage());
25  }
26 
27  public function testProPurchaseFailure()
28  {
29  $httpResponse = $this->getMockHttpResponse('ProPurchaseFailure.txt');
30  $response = new Response($this->getMockRequest(), $httpResponse->getBody());
31 
32  $this->assertFalse($response->isPending());
33  $this->assertFalse($response->isSuccessful());
34  $this->assertNull($response->getTransactionReference());
35  $this->assertSame('This transaction cannot be processed. Please enter a valid credit card expiration year.', $response->getMessage());
36  }
37 }
Omnipay\PayPal\Message\ResponseTest\testConstruct
testConstruct()
Definition: vendor/omnipay/paypal/tests/Message/ResponseTest.php:9
Omnipay\PayPal\Message\Response
Definition: lib/vendor/omnipay/paypal/src/Message/Response.php:11
Omnipay\PayPal\Message\ResponseTest\testProPurchaseSuccess
testProPurchaseSuccess()
Definition: vendor/omnipay/paypal/tests/Message/ResponseTest.php:16
Omnipay\PayPal\Message\ResponseTest\testProPurchaseFailure
testProPurchaseFailure()
Definition: vendor/omnipay/paypal/tests/Message/ResponseTest.php:27
Omnipay\PayPal\Message
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:6