|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Omnipay\Eway\Message; |
| 4 | + |
| 5 | +use Omnipay\Tests\TestCase; |
| 6 | + |
| 7 | +class RapidSharedUpdateCardRequestTest extends TestCase |
| 8 | +{ |
| 9 | + public function setUp() |
| 10 | + { |
| 11 | + $this->request = new RapidSharedUpdateCardRequest($this->getHttpClient(), $this->getHttpRequest()); |
| 12 | + $this->request->initialize(array( |
| 13 | + 'apiKey' => 'my api key', |
| 14 | + 'password' => 'secret', |
| 15 | + 'returnUrl' => 'https://www.example.com/return', |
| 16 | + 'cardReference' => '123456789' |
| 17 | + )); |
| 18 | + } |
| 19 | + |
| 20 | + public function testGetData() |
| 21 | + { |
| 22 | + $this->request->initialize(array( |
| 23 | + 'apiKey' => 'my api key', |
| 24 | + 'password' => 'secret', |
| 25 | + 'returnUrl' => 'https://www.example.com/return', |
| 26 | + 'cardReference' => '123456789', |
| 27 | + 'card' => array( |
| 28 | + 'title' => 'Mr', |
| 29 | + 'firstName' => 'Patrick', |
| 30 | + 'lastName' => 'Collison', |
| 31 | + 'country' => 'AU', |
| 32 | + ), |
| 33 | + )); |
| 34 | + |
| 35 | + $data = $this->request->getData(); |
| 36 | + |
| 37 | + $this->assertSame('Purchase', $data['TransactionType']); |
| 38 | + $this->assertSame('UpdateTokenCustomer', $data['Method']); |
| 39 | + $this->assertSame('https://www.example.com/return', $data['RedirectUrl']); |
| 40 | + $this->assertSame(0, $data['Payment']['TotalAmount']); |
| 41 | + $this->assertSame('Mr', $data['Customer']['Title']); |
| 42 | + $this->assertSame('Patrick', $data['Customer']['FirstName']); |
| 43 | + $this->assertSame('Collison', $data['Customer']['LastName']); |
| 44 | + $this->assertSame('au', $data['ShippingAddress']['Country']); |
| 45 | + $this->assertSame('123456789', $data['Customer']['TokenCustomerID']); |
| 46 | + } |
| 47 | + |
| 48 | + public function testSendSuccess() |
| 49 | + { |
| 50 | + $this->setMockHttpResponse('RapidSharedUpdateCardRequestSuccess.txt'); |
| 51 | + $response = $this->request->send(); |
| 52 | + |
| 53 | + $this->assertFalse($response->isSuccessful()); |
| 54 | + $this->assertTrue($response->isRedirect()); |
| 55 | + $this->assertSame('GET', $response->getRedirectMethod()); |
| 56 | + $this->assertSame('https://secure.ewaypayments.com/sharedpayment?AccessCode=F9802j0-O7sdVLnOcb_3IPryTxHDtKY8u_0pb10GbYq-Xjvbc-5Bc_LhI-oBIrTxTCjhOFn7Mq-CwpkLDja5-iu-Dr3DjVTr9u4yxSB5BckdbJqSA4WWydzDO0jnPWfBdKcWL', $response->getRedirectUrl()); |
| 57 | + $this->assertNull($response->getRedirectData()); |
| 58 | + $this->assertNull($response->getTransactionReference()); |
| 59 | + $this->assertNull($response->getMessage()); |
| 60 | + $this->assertNull($response->getCode()); |
| 61 | + $this->assertNotNull($response->getCardReference()); |
| 62 | + } |
| 63 | + |
| 64 | + public function testSendFailure() |
| 65 | + { |
| 66 | + $this->setMockHttpResponse('RapidSharedUpdateCardRequestFailure.txt'); |
| 67 | + $response = $this->request->send(); |
| 68 | + |
| 69 | + $this->assertFalse($response->isSuccessful()); |
| 70 | + $this->assertFalse($response->isRedirect()); |
| 71 | + $this->assertNull($response->getRedirectUrl()); |
| 72 | + $this->assertNull($response->getRedirectData()); |
| 73 | + $this->assertNull($response->getCardReference()); |
| 74 | + $this->assertNull($response->getTransactionReference()); |
| 75 | + $this->assertSame('V6040', $response->getCode()); |
| 76 | + } |
| 77 | + |
| 78 | + public function testCancelUrl() |
| 79 | + { |
| 80 | + $this->assertSame($this->request, $this->request->setCancelUrl('http://www.example.com')); |
| 81 | + $this->assertSame('http://www.example.com', $this->request->getCancelUrl()); |
| 82 | + } |
| 83 | + |
| 84 | + public function testLogoUrl() |
| 85 | + { |
| 86 | + $this->assertSame($this->request, $this->request->setLogoUrl('https://www.example.com/logo.jpg')); |
| 87 | + $this->assertSame('https://www.example.com/logo.jpg', $this->request->getLogoUrl()); |
| 88 | + } |
| 89 | + |
| 90 | + public function testHeaderText() |
| 91 | + { |
| 92 | + $this->assertSame($this->request, $this->request->setHeaderText('Header Text')); |
| 93 | + $this->assertSame('Header Text', $this->request->getHeaderText()); |
| 94 | + } |
| 95 | + |
| 96 | + public function testLanguage() |
| 97 | + { |
| 98 | + $this->assertSame($this->request, $this->request->setLanguage('EN')); |
| 99 | + $this->assertSame('EN', $this->request->getLanguage()); |
| 100 | + } |
| 101 | + |
| 102 | + public function testCustomerReadOnly() |
| 103 | + { |
| 104 | + $this->assertSame($this->request, $this->request->setCustomerReadOnly('true')); |
| 105 | + $this->assertSame('true', $this->request->getCustomerReadOnly()); |
| 106 | + } |
| 107 | + |
| 108 | + public function testCustomView() |
| 109 | + { |
| 110 | + $this->assertSame($this->request, $this->request->setCustomView('Bootstrap')); |
| 111 | + $this->assertSame('Bootstrap', $this->request->getCustomView()); |
| 112 | + } |
| 113 | + |
| 114 | + public function testVerifyCustomerPhone() |
| 115 | + { |
| 116 | + $this->assertSame($this->request, $this->request->setVerifyCustomerPhone('true')); |
| 117 | + $this->assertSame('true', $this->request->getVerifyCustomerPhone()); |
| 118 | + } |
| 119 | + |
| 120 | + public function testVerifyCustomerEmail() |
| 121 | + { |
| 122 | + $this->assertSame($this->request, $this->request->setVerifyCustomerEmail('true')); |
| 123 | + $this->assertSame('true', $this->request->getVerifyCustomerEmail()); |
| 124 | + } |
| 125 | + |
| 126 | +} |
0 commit comments