| Conditions | 1 |
| Paths | 1 |
| Total Lines | 222 |
| Code Lines | 153 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 60 | public static function providerProcess(): iterable |
||
| 61 | { |
||
| 62 | yield 'normal' => [ |
||
| 63 | [ |
||
| 64 | 'uppTransactionId' => '123456789012345678', |
||
| 65 | 'status' => 'success', |
||
| 66 | 'refno' => '1007', |
||
| 67 | 'merchantId' => '123456789', |
||
| 68 | 'amount' => '10000', |
||
| 69 | 'currency' => 'CHF', |
||
| 70 | 'responseMessage' => 'Payment was successful', |
||
| 71 | 'sign' => 'e591bc45430b1a14ad7e1a3a14a8218fb9a5ae944557c96366ec98feae6b17f4', |
||
| 72 | ], |
||
| 73 | 10096, |
||
| 74 | Money::CHF(15000), |
||
| 75 | [ |
||
| 76 | 'message' => [ |
||
| 77 | 'status' => 'success', |
||
| 78 | 'message' => 'Payment was successful', |
||
| 79 | ], |
||
| 80 | ], |
||
| 81 | ]; |
||
| 82 | yield 'duplicate' => [ |
||
| 83 | [ |
||
| 84 | 'uppTransactionId' => '123456789012345678', |
||
| 85 | 'status' => 'success', |
||
| 86 | 'refno' => '1007', |
||
| 87 | 'merchantId' => '123456789', |
||
| 88 | 'amount' => '10000', |
||
| 89 | 'currency' => 'CHF', |
||
| 90 | 'responseMessage' => 'Payment was successful', |
||
| 91 | 'sign' => 'e591bc45430b1a14ad7e1a3a14a8218fb9a5ae944557c96366ec98feae6b17f4', |
||
| 92 | ], |
||
| 93 | 10096, |
||
| 94 | Money::CHF(15000), |
||
| 95 | [ |
||
| 96 | 'message' => [ |
||
| 97 | 'status' => 'success', |
||
| 98 | 'message' => 'Payment was successful', |
||
| 99 | ], |
||
| 100 | ], |
||
| 101 | ]; |
||
| 102 | yield 'invalid HMAC signature' => [ |
||
| 103 | [ |
||
| 104 | 'uppTransactionId' => '123456789012345678', |
||
| 105 | 'status' => 'success', |
||
| 106 | 'refno' => '1007', |
||
| 107 | 'merchantId' => '123456789', |
||
| 108 | 'amount' => '10000', |
||
| 109 | 'currency' => 'CHF', |
||
| 110 | 'responseMessage' => 'Payment was successful', |
||
| 111 | 'sign' => 'a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0', |
||
| 112 | ], |
||
| 113 | 10096, |
||
| 114 | Money::CHF(5000), |
||
| 115 | [ |
||
| 116 | 'message' => [ |
||
| 117 | 'status' => 'error', |
||
| 118 | 'message' => 'Invalid HMAC signature', |
||
| 119 | ], |
||
| 120 | ], |
||
| 121 | ]; |
||
| 122 | yield 'missing HMAC signature' => [ |
||
| 123 | [ |
||
| 124 | 'uppTransactionId' => '123456789012345678', |
||
| 125 | 'status' => 'success', |
||
| 126 | 'refno' => '1007', |
||
| 127 | 'merchantId' => '123456789', |
||
| 128 | 'amount' => '10000', |
||
| 129 | 'currency' => 'CHF', |
||
| 130 | 'responseMessage' => 'Payment was successful', |
||
| 131 | ], |
||
| 132 | 10096, |
||
| 133 | Money::CHF(5000), |
||
| 134 | [ |
||
| 135 | 'message' => [ |
||
| 136 | 'status' => 'error', |
||
| 137 | 'message' => 'Missing HMAC signature', |
||
| 138 | ], |
||
| 139 | ], |
||
| 140 | ]; |
||
| 141 | yield 'user without account yet (child can credit householder)' => [ |
||
| 142 | [ |
||
| 143 | 'uppTransactionId' => '123456789012345678', |
||
| 144 | 'status' => 'success', |
||
| 145 | 'refno' => '1008', |
||
| 146 | 'merchantId' => '123456789', |
||
| 147 | 'amount' => '10000', |
||
| 148 | 'currency' => 'CHF', |
||
| 149 | 'responseMessage' => 'Payment was successful', |
||
| 150 | 'sign' => '3005b015945fb625ee25d7d804a65cc17f9dacd4fcba72329d34c8081230c146', |
||
| 151 | ], |
||
| 152 | 10096, |
||
| 153 | Money::CHF(15000), |
||
| 154 | [ |
||
| 155 | 'message' => [ |
||
| 156 | 'status' => 'success', |
||
| 157 | 'message' => 'Payment was successful', |
||
| 158 | ], |
||
| 159 | ], |
||
| 160 | ]; |
||
| 161 | yield 'error' => [ |
||
| 162 | [ |
||
| 163 | 'uppTransactionId' => '876543210987654321', |
||
| 164 | 'status' => 'error', |
||
| 165 | 'refno' => '1007', |
||
| 166 | 'merchantId' => '123456789', |
||
| 167 | 'errorMessage' => 'Dear Sir/Madam, Fire! fire! help me! All the best, Maurice Moss.', |
||
| 168 | 'sign' => '38151b15a4c680cccafe9dfff6edb236fa9bf1eeec65799b2720312ae9c4b233', |
||
| 169 | ], |
||
| 170 | 10096, |
||
| 171 | Money::CHF(5000), |
||
| 172 | [ |
||
| 173 | 'message' => [ |
||
| 174 | 'status' => 'error', |
||
| 175 | 'message' => 'Dear Sir/Madam, Fire! fire! help me! All the best, Maurice Moss.', |
||
| 176 | ], |
||
| 177 | ], |
||
| 178 | ]; |
||
| 179 | yield 'cancel' => [ |
||
| 180 | [ |
||
| 181 | 'uppTransactionId' => '876543210987654321', |
||
| 182 | 'status' => 'cancel', |
||
| 183 | 'refno' => '1007', |
||
| 184 | 'merchantId' => '123456789', |
||
| 185 | 'sign' => '38151b15a4c680cccafe9dfff6edb236fa9bf1eeec65799b2720312ae9c4b233', |
||
| 186 | ], |
||
| 187 | 10096, |
||
| 188 | Money::CHF(5000), |
||
| 189 | [ |
||
| 190 | 'message' => [ |
||
| 191 | 'status' => 'cancel', |
||
| 192 | 'message' => 'Cancelled', |
||
| 193 | ], |
||
| 194 | ], |
||
| 195 | ]; |
||
| 196 | yield 'invalid body' => [ |
||
| 197 | null, |
||
| 198 | null, |
||
| 199 | Money::CHF(0), |
||
| 200 | [ |
||
| 201 | 'message' => [ |
||
| 202 | 'status' => 'error', |
||
| 203 | 'message' => 'Parsed body is expected to be an array but got: NULL', |
||
| 204 | ], |
||
| 205 | ], |
||
| 206 | ]; |
||
| 207 | yield 'invalid status' => [ |
||
| 208 | [ |
||
| 209 | 'uppTransactionId' => '123456789012345678', |
||
| 210 | 'status' => 'non-existing-status', |
||
| 211 | 'refno' => '1007', |
||
| 212 | 'merchantId' => '123456789', |
||
| 213 | 'amount' => '10000', |
||
| 214 | 'currency' => 'CHF', |
||
| 215 | 'responseMessage' => 'Payment was successful', |
||
| 216 | 'sign' => 'e591bc45430b1a14ad7e1a3a14a8218fb9a5ae944557c96366ec98feae6b17f4', |
||
| 217 | ], |
||
| 218 | 10096, |
||
| 219 | Money::CHF(5000), |
||
| 220 | [ |
||
| 221 | 'message' => [ |
||
| 222 | 'status' => 'error', |
||
| 223 | 'message' => 'Unsupported status in Datatrans data: non-existing-status', |
||
| 224 | ], |
||
| 225 | ], |
||
| 226 | ]; |
||
| 227 | yield 'non-existing user' => [ |
||
| 228 | [ |
||
| 229 | 'uppTransactionId' => '123456789012345678', |
||
| 230 | 'status' => 'success', |
||
| 231 | 'merchantId' => '123456789', |
||
| 232 | 'amount' => '10000', |
||
| 233 | 'currency' => 'CHF', |
||
| 234 | 'responseMessage' => 'Payment was successful', |
||
| 235 | 'sign' => 'f875347d4c66a4f82717ae88f13812289db79b4c1cab4df4fe1c7fdbaaacff05', |
||
| 236 | ], |
||
| 237 | null, |
||
| 238 | Money::CHF(0), |
||
| 239 | [ |
||
| 240 | 'message' => [ |
||
| 241 | 'status' => 'error', |
||
| 242 | 'message' => 'Cannot create transactions without a user', |
||
| 243 | ], |
||
| 244 | ], |
||
| 245 | ]; |
||
| 246 | yield 'non-existing amount' => [ |
||
| 247 | [ |
||
| 248 | 'uppTransactionId' => '123456789012345678', |
||
| 249 | 'status' => 'success', |
||
| 250 | 'merchantId' => '123456789', |
||
| 251 | 'refno' => '1007', |
||
| 252 | 'currency' => 'CHF', |
||
| 253 | 'responseMessage' => 'Payment was successful', |
||
| 254 | 'sign' => 'e2ca709347d5bec5fd169cd3e1243a95d2eae0abf23a34e26e57698d30b3645d', |
||
| 255 | ], |
||
| 256 | 10096, |
||
| 257 | Money::CHF(5000), |
||
| 258 | [ |
||
| 259 | 'message' => [ |
||
| 260 | 'status' => 'error', |
||
| 261 | 'message' => 'Cannot create transactions without an amount', |
||
| 262 | ], |
||
| 263 | ], |
||
| 264 | ]; |
||
| 265 | yield 'invalid currency' => [ |
||
| 266 | [ |
||
| 267 | 'uppTransactionId' => '123456789012345678', |
||
| 268 | 'status' => 'success', |
||
| 269 | 'refno' => '1007', |
||
| 270 | 'merchantId' => '123456789', |
||
| 271 | 'amount' => '10000', |
||
| 272 | 'currency' => 'USD', |
||
| 273 | 'responseMessage' => 'Payment was successful', |
||
| 274 | 'sign' => 'a591b4bb76872f8fcb01f841e4b0cf092ae7c26561e93326243d7f48a9181849', |
||
| 275 | ], |
||
| 276 | 10096, |
||
| 277 | Money::CHF(5000), |
||
| 278 | [ |
||
| 279 | 'message' => [ |
||
| 280 | 'status' => 'error', |
||
| 281 | 'message' => 'Can only create transactions for CHF, but got: USD', |
||
| 282 | ], |
||
| 287 |