Odyssey
RDCTranzCapTest.php
1 <?php
2 use PHPUnit\Framework\TestCase;
3 
4 require_once("rdcTZtest.i");
5 require_once("hcuCommon.i");
6 
7 class RDCTranzCapTest extends TestCase
8 {
9 
10  /**
11  * set up the vendorinfo content
12  */
13  public function test_vendorInfo()
14  {
15  $this->assertTrue(true);
16  $vendorInfo = json_decode('{"Vendortime":1572870689,"userAgent":"Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 iPhone iPhone11,8","userIP":"172.56.10.140","accounts":{"D|803633|0|0":{"accounttype":"0","suffix":"803633000","certnumber":"0","acctclass":"D","description":"803633 / Regular Share - 0","tokn":"a7aa649acd1483aa2120ea6a528ef6f919c03ab7","Uid":"2414","trust":"primary","displaydesc":"803633 / Regular Share - 0","rdctype":"2","rdcdesc":"Savings","rdcmember":"803633","ScanLimitAmount":null},"D|803633|9|0":{"accounttype":"9","suffix":"8036330095","certnumber":"0","acctclass":"D","description":"803633 / Share Draft - 9","tokn":"0575e3a57ff283e2f22421f4f8066cfd0d989288","Uid":"2414","trust":"primary","displaydesc":"803633 / Share Draft - 9","rdctype":"1","rdcdesc":"Checking","rdcmember":"803633","ScanLimitAmount":null}},"depmessages":[],"tzToken":"urn:ietf:params:oauth:token-type:jwt eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IkFrRHp6V3ZmV0MwN0RNWE5TdFBBNTFZWFF3OCJ9.eyJpc3MiOiJodHRwczovL2xvZ2luLnRyYW56YWN0Lm9yZyIsImF1ZCI6Imh0dHBzOi8vd3d3LnRyYW56YWN0Lm9yZy8iLCJuYmYiOjE1NzI4NzA2MTAsImV4cCI6MTU3Mjg4NTAxMCwiaHR0cDovL2lkZW50aXR5c2VydmVyLnRoaW5rdGVjdHVyZS5jb20vY2xhaW1zL2NsaWVudCI6Ik1vYmlsZSIsImh0dHA6Ly9pZGVudGl0eXNlcnZlci50aGlua3RlY3R1cmUuY29tL2NsYWltcy9zY29wZSI6Imh0dHBzOi8vd3d3LnRyYW56YWN0Lm9yZy8iLCJodHRwOi8vaWRlbnRpdHlzZXJ2ZXIudGhpbmt0ZWN0dXJlLmNvbS9jbGFpbXMvY2xpZW50aWQiOiIzMyIsInVuaXF1ZV9uYW1lIjoiQ29ycE9uZUhvbWVDVSIsImF1dGhtZXRob2QiOiJPQXV0aDIiLCJhdXRoX3RpbWUiOiIyMDE5LTExLTA0VDEyOjMwOjEwLjE4NFoifQ.I4GaQHX90lRRur_B6o16F6IXwxRQbqSPjNyNV63WFzJKNQ1ZQbffmPn19J4fRvDdybuNU2PxQssz0hbRWeVcwgwdvA0ddHEOvwXZkfpISSW26h3nkqb3P-GN7n6lSaYo012_kudkvFJcwpsw9WbvXgst5T2an9j-6rn36hmVO9W4F8wEMz6WrTcGMaFur-88qfHKn4ZKuyaJbCixbqz4yBSsKgBCr8im5qMiLh4cRRaY6_aPfKyCcILhFj-SC--8Smz4-Zn3rMDfN4OudujR6raZLdXEV_jZ_cubCKxw8gJ96bfmuduWBU2SJ9F2wNsXyeMOQ7iu2jJ6PDG8vn2jUw","tzToken_expires":1572885004,"DepositStatus":"Failed","Message":"You must endorse your check "For Mobile Deposit Only".","DepositTime":"20191104123129"}',true);
17  return $vendorInfo;
18  }
19 
20  /**
21  * set up the rdcparms content
22  */
23  public function test_rdcParms()
24  {
25  $this->assertTrue(true);
26  $rdcParms = ['depositid' => 108015,
27  'acctid' => 'D|803633|9|0',
28  'amount' => 50000
29  ];
30  return $rdcParms;
31  }
32  /**
33  * @dataProvider DepositProvider
34  * @depends test_vendorInfo
35  * @depends test_rdcParms
36  */
37  // test_ in name is important to make test run
38  public function test_Deposit($response, $respHTTP, $respCURL, $examine, $expected, $vendorInfo, $rdcParms)
39  {
40  $postItem = Deposit_Responder($response, $respHTTP, $respCURL, $vendorInfo, $rdcParms);
41  // $this->assertArrayHasKey('message', $postItem, false, 'No message Found');
42  $this->assertArraySubset([$examine => $expected], $postItem['data'], false, print_r($postItem,true));
43  }
44 
45  /**
46  * @dataProvider PostItemProvider
47  */
48  // test_ in name is important to make test run
49  public function test_PostItem($response, $respHTTP, $respCURL, $examine, $expected)
50  {
51  $postItem = PostItem_Responder($response, $respHTTP, $respCURL, $vendorInfo);
52  // $this->assertArrayHasKey('message', $postItem, false, 'No message Found');
53  $this->assertArraySubset([$examine => $expected], $postItem['data'], false, print_r($postItem,true));
54  }
55 
56 
57  /**
58  * @dataProvider EmbCurlProvider
59  */
60  // test_ in name is important to make test run
61  public function test_EmbCurl($response, $respHTTP, $respCURL, $examine, $expected)
62  {
63  $embCurl = EmbCurl_Responder($response, $respHTTP, $respCURL);
64  // $this->assertArrayHasKey('message', $embCurl, false, 'No message Found');
65  $this->assertArraySubset([$examine => $expected], $embCurl, false, print_r($embCurl, true));
66  }
67 
68  public function DepositProvider()
69  {
70  return [
71  'valid response' => [
72  '{"BatchID":55118169,"ItemID":474254586,"WasSuccessful":true,"ErrorMessage":null}',
73  0,
74  0,
75  'rdcstatus',
76  'C'
77  ],
78  'rejected response' => [
79  '{"BatchID":null,"ItemID":null,"WasSuccessful":false,"ErrorMessage":"You must endorse your check \"For Mobile Deposit Only\"."}',
80  0,
81  0,
82  'rdcstatus',
83  'R'
84  ],
85 
86  'rejected bad image' => [
87  '{"BatchID":null,"ItemID":null,"WasSuccessful":false,"ErrorMessage":"Cannot read acct. data on bottom of check. Please retake. Ensure focus and all four corners visible."}',
88  0,
89  0,
90  'rdcstatus',
91  'R'
92  ],
93 
94  'rejected no endorsement' => [
95  '{"BatchID":null,"ItemID":null,"WasSuccessful":false,"ErrorMessage":"We cannot detect an endorsement. Please retake photo and ensure the check is endorsed."}',
96  0,
97  0,
98  'rdcstatus',
99  'R'
100  ],
101 
102 
103  'empty response' => [
104  '',
105  0,
106  0,
107  'rdcstatus',
108  'R'
109  ],
110 
111  'curlERR7 response' => [
112  'response',
113  0,
114  7,
115  'rdcstatus',
116  'R'
117  ],
118 
119  'httpERR403 response' => [
120  'response',
121  403,
122  0,
123  'rdcstatus',
124  'R'
125  ],
126 
127  ];
128  }
129 
130  public function PostItemProvider()
131  {
132  return [
133  'valid response' => [
134  '{"BatchID":55118169,"ItemID":474254586,"WasSuccessful":true,"ErrorMessage":null}',
135  0,
136  0,
137  'WasSuccessful',
138  true
139  ],
140  'rejected response' => [
141  '{"BatchID":null,"ItemID":null,"WasSuccessful":false,"ErrorMessage":"You must endorse your check \"For Mobile Deposit Only\"."}',
142  0,
143  0,
144  'WasSuccessful',
145  false
146  ],
147 
148  'rejected bad image' => [
149  '{"BatchID":null,"ItemID":null,"WasSuccessful":false,"ErrorMessage":"Cannot read acct. data on bottom of check. Please retake. Ensure focus and all four corners visible."}',
150  0,
151  0,
152  'WasSuccessful',
153  false
154  ],
155 
156  'rejected no endorsement' => [
157  '{"BatchID":null,"ItemID":null,"WasSuccessful":false,"ErrorMessage":"We cannot detect an endorsement. Please retake photo and ensure the check is endorsed."}',
158  0,
159  0,
160  'WasSuccessful',
161  false
162  ],
163 
164  'empty response' => [
165  '',
166  0,
167  0,
168  'error',
169  'hcuE'
170  ],
171 
172  'curlERR7 response' => [
173  'response',
174  0,
175  7,
176  'error',
177  'hcuC7'
178  ],
179 
180  'httpERR403 response' => [
181  'response',
182  403,
183  0,
184  'error',
185  'hcuH403'
186  ],
187 
188  ];
189  }
190  public function EmbCurlProvider()
191  {
192  return [
193  'valid response' => [
194  '{"BatchID":55118169,"ItemID":474254586,"WasSuccessful":true,"ErrorMessage":null}',
195  0,
196  0,
197  'WasSuccessful',
198  true
199  ],
200 
201  'rejected response' => [
202  '{"BatchID":null,"ItemID":null,"WasSuccessful":false,"ErrorMessage":"You must endorse your check \"For Mobile Deposit Only\"."}',
203  0,
204  0,
205  'WasSuccessful',
206  false
207  ],
208 
209  'empty response' => [
210  '',
211  0,
212  0,
213  'error',
214  'hcuE'
215  ],
216 
217  'curlERR7 response' => [
218  'response',
219  0,
220  7,
221  'error',
222  'hcuC7'
223  ],
224 
225  'httpERR403 response' => [
226  'response',
227  403,
228  0,
229  'error',
230  'hcuH403'
231  ],
232 
233  'layered response' => [
234  '[ { "Property": "", "Message": "Cannot add a user that already exists.", "Value": { "UserId": "3974", "AccountNumber": "0000397450", "FirstName": null, "LastName": null, "PhoneNumber": null, "EmailAddress": "luvinfrogs.sh@gmail.com", "AccountType": 1 } } ]',
235  0,
236  0,
237  'error',
238  'tzE'
239  ],
240 
241  'badJson response' => [
242  'not json',
243  0,
244  0,
245  'error',
246  'tzE'
247  ],
248 
249  // 'getHistory response' => [
250  // '[{"BatchID":39637,"ItemID":152000,"Created":"2019-09-23T10:49:10.393","Amount":5.0000,"AccountNumber":"0000397450","ReviewComments":null,"AccountType":1,"ItemStatus":4},{"BatchID":39636,"ItemID":151999,"Created":"2019-09-23T10:48:03.363","Amount":5.0000,"AccountNumber":"0000397450","ReviewComments":null,"AccountType":1,"ItemStatus":4},{"BatchID":39635,"ItemID":151998,"Created":"2019-09-23T10:46:29.447","Amount":41.9900,"AccountNumber":"0000397450","ReviewComments":null,"AccountType":1,"ItemStatus":4}]',
251  // 0,
252  // 0,
253  // 'ItemID',
254  // '152000'
255  // ],
256 
257  ];
258  }
259 }
test_PostItem($response, $respHTTP, $respCURL, $examine, $expected)
test_EmbCurl($response, $respHTTP, $respCURL, $examine, $expected)
test_Deposit($response, $respHTTP, $respCURL, $examine, $expected, $vendorInfo, $rdcParms)