Open Journal Systems  3.3.0
lib/vendor/omnipay/paypal/tests/Message/RestResponseTest.php
1 <?php
2 
3 namespace Omnipay\PayPal\Message;
4 
5 use Omnipay\Tests\TestCase;
6 
7 class RestResponseTest extends TestCase
8 {
9  public function testPurchaseSuccess()
10  {
11  $httpResponse = $this->getMockHttpResponse('RestPurchaseSuccess.txt');
12  $response = new RestResponse($this->getMockRequest(), $httpResponse->json(), $httpResponse->getStatusCode());
13 
14  $this->assertTrue($response->isSuccessful());
15  $this->assertSame('44E89981F8714392Y', $response->getTransactionReference());
16  $this->assertNull($response->getMessage());
17  }
18 
19  public function testPurchaseFailure()
20  {
21  $httpResponse = $this->getMockHttpResponse('RestPurchaseFailure.txt');
22  $response = new RestResponse($this->getMockRequest(), $httpResponse->json(), $httpResponse->getStatusCode());
23 
24  $this->assertFalse($response->isSuccessful());
25  $this->assertNull($response->getTransactionReference());
26  $this->assertSame('Invalid request - see details', $response->getMessage());
27  }
28 
29  public function testCompletePurchaseSuccess()
30  {
31  $httpResponse = $this->getMockHttpResponse('RestCompletePurchaseSuccess.txt');
32  $response = new RestResponse($this->getMockRequest(), $httpResponse->json(), $httpResponse->getStatusCode());
33 
34  $this->assertTrue($response->isSuccessful());
35  $this->assertSame('9EA05739TH369572R', $response->getTransactionReference());
36  $this->assertNull($response->getMessage());
37  }
38 
39  public function testCompletePurchaseFailure()
40  {
41  $httpResponse = $this->getMockHttpResponse('RestCompletePurchaseFailure.txt');
42  $response = new RestResponse($this->getMockRequest(), $httpResponse->json(), $httpResponse->getStatusCode());
43 
44  $this->assertFalse($response->isSuccessful());
45  $this->assertNull($response->getTransactionReference());
46  $this->assertSame('This request is invalid due to the current state of the payment', $response->getMessage());
47  }
48 
49  public function testTokenFailure()
50  {
51  $httpResponse = $this->getMockHttpResponse('RestTokenFailure.txt');
52  $response = new RestResponse($this->getMockRequest(), $httpResponse->json(), $httpResponse->getStatusCode());
53 
54  $this->assertFalse($response->isSuccessful());
55  $this->assertSame('Client secret does not match for this client', $response->getMessage());
56  }
57 
58  public function testAuthorizeSuccess()
59  {
60  $httpResponse = $this->getMockHttpResponse('RestAuthorizationSuccess.txt');
61  $response = new RestResponse($this->getMockRequest(), $httpResponse->json(), $httpResponse->getStatusCode());
62 
63  $this->assertTrue($response->isSuccessful());
64  $this->assertSame('58N7596879166930B', $response->getTransactionReference());
65  $this->assertNull($response->getMessage());
66  }
67 
68  public function testCreateCardSuccess()
69  {
70  $httpResponse = $this->getMockHttpResponse('RestCreateCardSuccess.txt');
71  $response = new RestResponse($this->getMockRequest(), $httpResponse->json(), $httpResponse->getStatusCode());
72 
73  $this->assertTrue($response->isSuccessful());
74  $this->assertSame('CARD-70E78145XN686604FKO3L6OQ', $response->getCardReference());
75  $this->assertNull($response->getMessage());
76  }
77 }
Omnipay\PayPal\Message\RestResponseTest\testCreateCardSuccess
testCreateCardSuccess()
Definition: lib/vendor/omnipay/paypal/tests/Message/RestResponseTest.php:68
Omnipay\PayPal\Message\RestResponseTest\testAuthorizeSuccess
testAuthorizeSuccess()
Definition: lib/vendor/omnipay/paypal/tests/Message/RestResponseTest.php:58
Omnipay\PayPal\Message\RestResponseTest\testPurchaseFailure
testPurchaseFailure()
Definition: lib/vendor/omnipay/paypal/tests/Message/RestResponseTest.php:19
Omnipay\PayPal\Message\RestResponseTest\testPurchaseSuccess
testPurchaseSuccess()
Definition: lib/vendor/omnipay/paypal/tests/Message/RestResponseTest.php:9
Omnipay\PayPal\Message\RestResponseTest\testCompletePurchaseSuccess
testCompletePurchaseSuccess()
Definition: lib/vendor/omnipay/paypal/tests/Message/RestResponseTest.php:29
Omnipay\PayPal\Message\RestResponse
Definition: lib/vendor/omnipay/paypal/src/Message/RestResponse.php:14
Omnipay\PayPal\Message\RestResponseTest\testCompletePurchaseFailure
testCompletePurchaseFailure()
Definition: lib/vendor/omnipay/paypal/tests/Message/RestResponseTest.php:39
Omnipay\PayPal\Message\RestResponseTest
Definition: lib/vendor/omnipay/paypal/tests/Message/RestResponseTest.php:7
Omnipay\PayPal\Message\RestResponseTest\testTokenFailure
testTokenFailure()
Definition: lib/vendor/omnipay/paypal/tests/Message/RestResponseTest.php:49
Omnipay\PayPal\Message
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:6