-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathFetchSubscriptionInvoiceReferencesRequestTest.php
More file actions
132 lines (109 loc) · 4.35 KB
/
FetchSubscriptionInvoiceReferencesRequestTest.php
File metadata and controls
132 lines (109 loc) · 4.35 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
namespace Omnipay\Vindicia\Message;
use Omnipay\Vindicia\TestFramework\Mocker;
use Omnipay\Vindicia\TestFramework\DataFaker;
use Omnipay\Vindicia\TestFramework\SoapTestCase;
class FetchSubscriptionInvoiceReferencesRequestTest extends SoapTestCase
{
/**
* @return void
*/
public function setUp(): void
{
$this->faker = new DataFaker();
$this->subscriptionId = $this->faker->subscriptionId();
$this->invoiceState = $this->faker->invoiceState();
$this->request = new FetchSubscriptionInvoiceReferencesRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize(
array(
'subscriptionId' => $this->subscriptionId,
'invoiceState' => $this->invoiceState
)
);
$this->subscriptionReference = $this->faker->subscriptionReference();
$this->invoiceReference = $this->faker->invoiceReference();
}
/**
* @return void
*/
public function testSubscriptionId()
{
$request = Mocker::mock('\Omnipay\Vindicia\Message\FetchSubscriptionInvoiceReferencesRequest')->makePartial();
$request->initialize();
$this->assertSame($request, $request->setSubscriptionId($this->subscriptionId));
$this->assertSame($this->subscriptionId, $request->getSubscriptionId());
}
/**
* @return void
*/
public function testSubscriptionReference()
{
$request = Mocker::mock('\Omnipay\Vindicia\Message\FetchSubscriptionInvoiceReferencesRequest')->makePartial();
$request->initialize();
$this->assertSame($request, $request->setSubscriptionReference($this->subscriptionReference));
$this->assertSame($this->subscriptionReference, $request->getSubscriptionReference());
}
/**
* @return void
*/
public function testInvoiceState()
{
$request = Mocker::mock('\Omnipay\Vindicia\Message\FetchSubscriptionInvoiceReferencesRequest')->makePartial();
$request->initialize();
$this->assertSame($request, $request->setInvoiceState($this->invoiceState));
$this->assertSame($this->invoiceState, $request->getInvoiceState());
}
/**
* @return void
*/
public function testGetData()
{
$data = $this->request->getData();
$this->assertSame($this->subscriptionId, $data['autobill']->merchantAutoBillId);
$this->assertSame('fetchInvoiceNumbers', $data['action']);
$this->assertSame($this->invoiceState, $data['invoicestate']);
}
/**
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
* @expectedExceptionMessage Either the subscriptionId or subscriptionReference parameter is required.
* @return void
*/
public function testSubscriptionIdOrReferenceRequired()
{
$this->request->setSubscriptionId(null);
$this->request->setSubscriptionReference(null);
$this->request->getData();
}
/**
* @return void
*/
public function testSendSuccess()
{
$this->setMockSoapResponse('FetchSubscriptionInvoiceReferencesSuccess.xml', array(
'INVOICE_REFERENCE' => $this->invoiceReference
));
$response = $this->request->send();
$this->assertTrue($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertFalse($response->isPending());
$this->assertSame('OK', $response->getMessage());
$invoice_references_array = $response->getInvoiceReferences();
$this->assertNotNull($invoice_references_array);
$this->assertEquals(2, count($invoice_references_array));
$this->assertSame($this->invoiceReference, $invoice_references_array[0]);
$this->assertSame(AbstractRequest::TEST_ENDPOINT . '/18.0/AutoBill.wsdl', $this->getLastEndpoint());
}
/**
* @return void
*/
public function testSendFailure()
{
$this->setMockSoapResponse('FetchSubscriptionInvoiceReferencesFailure.xml');
$response = $this->request->send();
$this->assertFalse($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertFalse($response->isPending());
$this->assertSame('400', $response->getCode());
$this->assertSame('Unable to load AutoBill: ', $response->getMessage());
}
}