-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathFetchPaymentMethodsRequestTest.php
More file actions
117 lines (97 loc) · 3.66 KB
/
FetchPaymentMethodsRequestTest.php
File metadata and controls
117 lines (97 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
namespace Omnipay\Vindicia\Message;
use Omnipay\Vindicia\TestFramework\Mocker;
use Omnipay\Vindicia\TestFramework\DataFaker;
use Omnipay\Vindicia\TestFramework\SoapTestCase;
class FetchPaymentMethodsRequestTest extends SoapTestCase
{
/**
* @return void
*/
public function setUp(): void
{
$this->faker = new DataFaker();
$this->customerId = $this->faker->customerId();
$this->customerReference = $this->faker->customerReference();
$this->request = new FetchPaymentMethodsRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize(
array(
'customerId' => $this->customerId,
'customerReference' => $this->customerReference
)
);
}
/**
* @return void
*/
public function testCustomerId()
{
$request = Mocker::mock('\Omnipay\Vindicia\Message\FetchPaymentMethodsRequest')->makePartial();
$request->initialize();
$this->assertSame($request, $request->setCustomerId($this->customerId));
$this->assertSame($this->customerId, $request->getCustomerId());
}
/**
* @return void
*/
public function testCustomerReference()
{
$request = Mocker::mock('\Omnipay\Vindicia\Message\FetchPaymentMethodsRequest')->makePartial();
$request->initialize();
$this->assertSame($request, $request->setCustomerReference($this->customerReference));
$this->assertSame($this->customerReference, $request->getCustomerReference());
}
/**
* @return void
*/
public function testGetData()
{
$data = $this->request->getData();
$this->assertSame($this->customerId, $data['account']->merchantAccountId);
$this->assertSame($this->customerReference, $data['account']->VID);
$this->assertSame('fetchByAccount', $data['action']);
}
/**
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
* @expectedExceptionMessage The customerId parameter or the customerReference parameter is required.
* @return void
*/
public function testCustomerIdOrReferenceRequired()
{
$this->request->setCustomerId(null);
$this->request->setCustomerReference(null);
$this->request->getData();
}
/**
* @return void
*/
public function testSendSuccess()
{
$this->setMockSoapResponse('FetchPaymentMethodsSuccess.xml');
$response = $this->request->send();
$this->assertTrue($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertFalse($response->isPending());
$this->assertSame('OK', $response->getMessage());
$paymentMethods = $response->getPaymentMethods();
$this->assertTrue(is_array($paymentMethods));
$this->assertSame(2, count($paymentMethods));
$this->assertNotNull($paymentMethods[0]->getId());
$this->assertNotNull($paymentMethods[1]->getId());
$this->assertSame(AbstractRequest::TEST_ENDPOINT . '/18.0/PaymentMethod.wsdl', $this->getLastEndpoint());
}
/**
* @return void
*/
public function testSendFailure()
{
$this->setMockSoapResponse('FetchPaymentMethodsFailure.xml');
$response = $this->request->send();
$this->assertFalse($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertFalse($response->isPending());
$this->assertSame('404', $response->getCode());
$this->assertSame('Account not found.', $response->getMessage());
$this->assertNull($response->getPaymentMethods());
}
}