Skip to content

Commit 81bbfa1

Browse files
committed
Tests for ARBGetSubscription and GetCustomerPaymentProfileList
Adds unit tests for *ARBGetSubscription *GetCustomerPaymentProfileList Signed-off-by: Srijan Misra <srmisra@visa.com>
1 parent b7ce0f3 commit 81bbfa1

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

tests/Controller_Test.php

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,85 @@ public function testARBGetSubscriptionList()
5454
}
5555
}
5656

57+
public function testARBGetSubscription()
58+
{
59+
$name = (defined('AUTHORIZENET_API_LOGIN_ID') && ''!=AUTHORIZENET_API_LOGIN_ID) ? AUTHORIZENET_API_LOGIN_ID : getenv("api_login_id");
60+
$transactionKey = (defined('AUTHORIZENET_TRANSACTION_KEY') && ''!=AUTHORIZENET_TRANSACTION_KEY) ? AUTHORIZENET_TRANSACTION_KEY : getenv("transaction_key");
61+
62+
$merchantAuthentication = new net\authorize\api\contract\v1\MerchantAuthenticationType();
63+
$merchantAuthentication->setName($name);
64+
$merchantAuthentication->setTransactionKey($transactionKey);
65+
66+
$refId = 'ref' . time();
67+
68+
$request = new net\authorize\api\contract\v1\ARBGetSubscriptionRequest();
69+
$request->setMerchantAuthentication($merchantAuthentication);
70+
$request->setRefId($refId);
71+
$request->setSubscriptionId("2930242");
72+
73+
$controller = new net\authorize\api\controller\ARBGetSubscriptionController($request);
74+
75+
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
76+
77+
$this->assertNotNull($response, "null response");
78+
$this->assertNotNull($response->getMessages());
79+
80+
$this->assertEquals("Ok", $response->getMessages()->getResultCode());
81+
$this->assertEquals($response->getRefId(), $refId);
82+
$this->assertTrue(0 < count($response->getMessages()));
83+
84+
foreach ($response->getMessages() as $message)
85+
{
86+
$this->assertEquals("I00001", $message->getCode());
87+
$this->assertEquals("Successful.", $response->getText());
88+
}
89+
}
90+
91+
public function testGetCustomerPaymentProfileList()
92+
{
93+
$name = (defined('AUTHORIZENET_API_LOGIN_ID') && ''!=AUTHORIZENET_API_LOGIN_ID) ? AUTHORIZENET_API_LOGIN_ID : getenv("api_login_id");
94+
$transactionKey = (defined('AUTHORIZENET_TRANSACTION_KEY') && ''!=AUTHORIZENET_TRANSACTION_KEY) ? AUTHORIZENET_TRANSACTION_KEY : getenv("transaction_key");
95+
96+
$merchantAuthentication = new net\authorize\api\contract\v1\MerchantAuthenticationType();
97+
$merchantAuthentication->setName($name);
98+
$merchantAuthentication->setTransactionKey($transactionKey);
99+
100+
$refId = 'ref' . time();
101+
102+
$paging = new net\authorize\api\contract\v1\PagingType();
103+
$paging->setLimit("1000");
104+
$paging->setOffset("1");
105+
106+
107+
$sorting = new net\authorize\api\contract\v1\CustomerPaymentProfileSortingType();
108+
$sorting->setOrderBy("id");
109+
$sorting->setOrderDescending("false");
110+
111+
$request = new net\authorize\api\contract\v1\GetCustomerPaymentProfileListRequest();
112+
$request->setMerchantAuthentication($merchantAuthentication);
113+
$request->setRefId($refId);
114+
$request->setPaging($paging);
115+
$request->setSorting($sorting);
116+
$request->setSearchType("cardsExpiringInMonth");
117+
$request->setMonth("2020-12");
118+
119+
$controller = new net\authorize\api\controller\GetCustomerPaymentProfileListController($request);
120+
$response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
121+
122+
$this->assertNotNull($response, "null response");
123+
$this->assertNotNull($response->getMessages());
124+
125+
$this->assertEquals("Ok", $response->getMessages()->getResultCode());
126+
$this->assertEquals($response->getRefId(), $refId);
127+
$this->assertTrue(0 < count($response->getMessages()));
128+
129+
foreach ($response->getMessages() as $message)
130+
{
131+
$this->assertEquals("I00001", $message->getCode());
132+
$this->assertEquals("Successful.", $response->getText());
133+
}
134+
}
135+
57136
public function testDecryptPaymentData()
58137
{
59138
//$this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO

0 commit comments

Comments
 (0)