1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Swiss Payment Slip |
4
|
|
|
* |
5
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT License |
6
|
|
|
* @copyright 2012-2016 Some nice Swiss guys |
7
|
|
|
* @author Marc Würth [email protected] |
8
|
|
|
* @author Manuel Reinhard <[email protected]> |
9
|
|
|
* @author Peter Siska <[email protected]> |
10
|
|
|
* @link https://github.com/ravage84/SwissPaymentSlip/ |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace SwissPaymentSlip\SwissPaymentSlip\Tests; |
14
|
|
|
|
15
|
|
|
use SwissPaymentSlip\SwissPaymentSlip\OrangePaymentSlipData; |
16
|
|
|
use SwissPaymentSlip\SwissPaymentSlip\Exception\ReferenceNumberException; |
17
|
|
|
use SwissPaymentSlip\SwissPaymentSlip\Exception\BankingCustomerIdException; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Tests for the OrangePaymentSlipData class |
21
|
|
|
* |
22
|
|
|
* @coversDefaultClass SwissPaymentSlip\SwissPaymentSlip\OrangePaymentSlipData |
23
|
|
|
*/ |
24
|
|
|
class OrangePaymentSlipDataTest extends \PHPUnit_Framework_TestCase |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* The object under test |
28
|
|
|
* |
29
|
|
|
* @var OrangePaymentSlipData |
30
|
|
|
*/ |
31
|
|
|
protected $slipData; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Setup the object under test |
35
|
|
|
* |
36
|
|
|
* @return void |
37
|
|
|
*/ |
38
|
|
|
protected function setUp() |
39
|
|
|
{ |
40
|
|
|
$this->slipData = new OrangePaymentSlipData(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Tests the getWithReferenceNumber and setWithReferenceNumber methods |
45
|
|
|
* |
46
|
|
|
* @return void |
47
|
|
|
* @covers ::setWithReferenceNumber |
48
|
|
|
* @covers ::getWithReferenceNumber |
49
|
|
|
* @covers ::isBool |
50
|
|
|
* @covers ::setReferenceNumber |
51
|
|
|
* @covers ::getReferenceNumber |
52
|
|
|
*/ |
53
|
|
|
public function testSetWithReferenceNumber() |
54
|
|
|
{ |
55
|
|
|
// Test default values |
56
|
|
|
$this->assertEquals('', $this->slipData->getReferenceNumber()); |
57
|
|
|
$this->assertTrue($this->slipData->getWithReferenceNumber()); |
58
|
|
|
|
59
|
|
|
// Set data when enabled, also check for returned instance |
60
|
|
|
$returned = $this->slipData->setReferenceNumber('0123456789'); |
61
|
|
|
$this->assertInstanceOf('SwissPaymentSlip\SwissPaymentSlip\OrangePaymentSlipData', $returned); |
62
|
|
|
$this->assertEquals('0123456789', $this->slipData->getReferenceNumber()); |
63
|
|
|
|
64
|
|
|
// Disable feature, also check for returned instance |
65
|
|
|
$returned = $this->slipData->setWithReferenceNumber(false); |
66
|
|
|
$this->assertInstanceOf('SwissPaymentSlip\SwissPaymentSlip\OrangePaymentSlipData', $returned); |
67
|
|
|
$this->assertFalse($this->slipData->getWithReferenceNumber()); |
68
|
|
|
|
69
|
|
|
// Re-enable feature, using no parameter |
70
|
|
|
$this->slipData->setWithReferenceNumber(); |
71
|
|
|
$this->assertTrue($this->slipData->getWithReferenceNumber()); |
72
|
|
|
$this->assertEquals('', $this->slipData->getReferenceNumber()); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Tests the setReferenceNumber method when disabled |
77
|
|
|
* |
78
|
|
|
* @return void |
79
|
|
|
* @expectedException \SwissPaymentSlip\SwissPaymentSlip\Exception\DisabledDataException |
80
|
|
|
* @expectedExceptionMessage You are accessing the disabled reference number. You need to re-enable it first. |
81
|
|
|
* @covers ::setReferenceNumber |
82
|
|
|
*/ |
83
|
|
|
public function testSetReferenceNumberWhenDisabled() |
84
|
|
|
{ |
85
|
|
|
$this->slipData->setWithReferenceNumber(false); |
86
|
|
|
$this->slipData->setReferenceNumber(''); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Tests the getReferenceNumber method when disabled |
91
|
|
|
* |
92
|
|
|
* @return void |
93
|
|
|
* @expectedException \SwissPaymentSlip\SwissPaymentSlip\Exception\DisabledDataException |
94
|
|
|
* @expectedExceptionMessage You are accessing the disabled reference number. You need to re-enable it first. |
95
|
|
|
* @covers ::getReferenceNumber |
96
|
|
|
*/ |
97
|
|
|
public function testGetReferenceNumberWhenDisabled() |
98
|
|
|
{ |
99
|
|
|
$this->slipData->setWithReferenceNumber(false); |
100
|
|
|
$this->slipData->getReferenceNumber(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Tests the setWithReferenceNumber method with an invalid parameter |
105
|
|
|
* |
106
|
|
|
* @return void |
107
|
|
|
* @expectedException \InvalidArgumentException |
108
|
|
|
* @expectedExceptionMessage $withReferenceNumber is not a boolean. |
109
|
|
|
* @covers ::setWithReferenceNumber |
110
|
|
|
* @covers ::isBool |
111
|
|
|
*/ |
112
|
|
|
public function testSetWithReferenceNumberInvalidParameter() |
113
|
|
|
{ |
114
|
|
|
$this->slipData->setWithReferenceNumber(1); |
|
|
|
|
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Tests the getWithBankingCustomerId and setWithBankingCustomerId methods |
119
|
|
|
* |
120
|
|
|
* @return void |
121
|
|
|
* @covers ::setWithBankingCustomerId |
122
|
|
|
* @covers ::getWithBankingCustomerId |
123
|
|
|
* @covers ::isBool |
124
|
|
|
* @covers ::setBankingCustomerId |
125
|
|
|
* @covers ::getBankingCustomerId |
126
|
|
|
*/ |
127
|
|
|
public function testSetWithBankingCustomerId() |
128
|
|
|
{ |
129
|
|
|
// Test default values |
130
|
|
|
$this->assertEquals('', $this->slipData->getBankingCustomerId()); |
131
|
|
|
$this->assertTrue($this->slipData->getWithBankingCustomerId()); |
132
|
|
|
|
133
|
|
|
// Set data when enabled, also check for returned instance |
134
|
|
|
$returned = $this->slipData->setBankingCustomerId('012345'); |
135
|
|
|
$this->assertInstanceOf('SwissPaymentSlip\SwissPaymentSlip\OrangePaymentSlipData', $returned); |
136
|
|
|
$this->assertEquals('012345', $this->slipData->getBankingCustomerId()); |
137
|
|
|
|
138
|
|
|
// Disable feature, also check for returned instance |
139
|
|
|
$returned = $this->slipData->setWithBankingCustomerId(false); |
140
|
|
|
$this->assertInstanceOf('SwissPaymentSlip\SwissPaymentSlip\OrangePaymentSlipData', $returned); |
141
|
|
|
$this->assertFalse($this->slipData->getWithBankingCustomerId()); |
142
|
|
|
|
143
|
|
|
// Re-enable feature, using no parameter |
144
|
|
|
$this->slipData->setWithBankingCustomerId(); |
145
|
|
|
$this->assertTrue($this->slipData->getWithBankingCustomerId()); |
146
|
|
|
$this->assertEquals('', $this->slipData->getBankingCustomerId()); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Tests the setBankingCustomerId method when disabled |
151
|
|
|
* |
152
|
|
|
* @return void |
153
|
|
|
* @expectedException \SwissPaymentSlip\SwissPaymentSlip\Exception\DisabledDataException |
154
|
|
|
* @expectedExceptionMessage You are accessing the disabled banking customer ID. You need to re-enable it first. |
155
|
|
|
* @covers ::setBankingCustomerId |
156
|
|
|
*/ |
157
|
|
|
public function testSetBankingCustomerIdNumberWhenDisabled() |
158
|
|
|
{ |
159
|
|
|
$this->slipData->setWithBankingCustomerId(false); |
160
|
|
|
$this->slipData->setBankingCustomerId(''); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Tests the getBankingCustomerId method when disabled |
165
|
|
|
* |
166
|
|
|
* @return void |
167
|
|
|
* @expectedException \SwissPaymentSlip\SwissPaymentSlip\Exception\DisabledDataException |
168
|
|
|
* @expectedExceptionMessage You are accessing the disabled banking customer ID. You need to re-enable it first. |
169
|
|
|
* @covers ::getBankingCustomerId |
170
|
|
|
*/ |
171
|
|
|
public function testGetBankingCustomerIdNumberWhenDisabled() |
172
|
|
|
{ |
173
|
|
|
$this->slipData->setWithBankingCustomerId(false); |
174
|
|
|
$this->slipData->getBankingCustomerId(); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Tests the setWithBankingCustomerId method with an invalid parameter |
179
|
|
|
* |
180
|
|
|
* @return void |
181
|
|
|
* @expectedException \InvalidArgumentException |
182
|
|
|
* @expectedExceptionMessage $withBankingCustomerId is not a boolean. |
183
|
|
|
* @covers ::setWithBankingCustomerId |
184
|
|
|
* @covers ::isBool |
185
|
|
|
*/ |
186
|
|
|
public function testSetWithBankingCustomerIdInvalidParameter() |
187
|
|
|
{ |
188
|
|
|
$this->slipData->setWithBankingCustomerId(1); |
|
|
|
|
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* Tests the getCompleteReferenceNumber method |
193
|
|
|
* Throws exception because of banking customer ID with reference number is longer than max allowed (26) |
194
|
|
|
* |
195
|
|
|
* @return void |
196
|
|
|
* @covers ::setReferenceNumber |
197
|
|
|
*/ |
198
|
|
|
public function testSetReferenceNumberLengthExceptionA() |
199
|
|
|
{ |
200
|
|
|
$this->setExpectedException(ReferenceNumberException::class); |
201
|
|
|
$this->slipData->setReferenceNumber('752003345590001277777777777'); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* Tests the getCompleteReferenceNumber method |
206
|
|
|
* Throws exception because of banking customer ID with reference number is longer than max allowed (26) |
207
|
|
|
* |
208
|
|
|
* @return void |
209
|
|
|
* @covers ::setReferenceNumber |
210
|
|
|
*/ |
211
|
|
|
public function testSetReferenceNumberLengthExceptionB() |
212
|
|
|
{ |
213
|
|
|
$this->setExpectedException(ReferenceNumberException::class); |
214
|
|
|
$this->slipData->setBankingCustomerId('1234567890', 10); |
215
|
|
|
$this->slipData->setReferenceNumber('75200334559000123'); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* Tests the setBankingCustomerId method |
220
|
|
|
* Throws exception because of banking customer ID is longer than max (10) |
221
|
|
|
* |
222
|
|
|
* @return void |
223
|
|
|
* @covers ::setBankingCustomerId |
224
|
|
|
*/ |
225
|
|
|
public function testsetBankingCustomerIdLengthExceptionA() |
226
|
|
|
{ |
227
|
|
|
$this->setExpectedException(BankingCustomerIdException::class); |
228
|
|
|
$this->slipData->setBankingCustomerId('12345678901', 11); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* Tests the setBankingCustomerId method |
233
|
|
|
* Throws exception because of banking customer ID is longer than expected by default (6) |
234
|
|
|
* |
235
|
|
|
* @return void |
236
|
|
|
* @covers ::setBankingCustomerId |
237
|
|
|
*/ |
238
|
|
|
public function testsetBankingCustomerIdLengthExceptionB() |
239
|
|
|
{ |
240
|
|
|
$this->setExpectedException(BankingCustomerIdException::class); |
241
|
|
|
$this->slipData->setBankingCustomerId('1234567890'); |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* Tests the setBankingCustomerId method |
246
|
|
|
* Throws exception because of banking customer ID with reference number is longer than max allowed (26) |
247
|
|
|
* |
248
|
|
|
* @return void |
249
|
|
|
* @covers ::setBankingCustomerId |
250
|
|
|
*/ |
251
|
|
|
public function testsetBankingCustomerIdLengthExceptionC() |
252
|
|
|
{ |
253
|
|
|
$this->setExpectedException(ReferenceNumberException::class); |
254
|
|
|
$this->slipData->setReferenceNumber('75200334559000123'); |
255
|
|
|
$this->slipData->setBankingCustomerId('1234567890', 10); |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* Tests the getCompleteReferenceNumber method |
260
|
|
|
* |
261
|
|
|
* @return void |
262
|
|
|
* @covers ::getCompleteReferenceNumber |
263
|
|
|
* @covers ::appendCheckDigit |
264
|
|
|
* @covers ::breakStringIntoBlocks |
265
|
|
|
* @covers ::modulo10 |
266
|
|
|
*/ |
267
|
|
|
public function testGetCompleteReferenceNumber() |
268
|
|
|
{ |
269
|
|
|
// Test with reference number & banking customer ID |
270
|
|
|
$this->slipData->setReferenceNumber('7520033455900012'); |
271
|
|
|
|
272
|
|
|
$this->slipData->setBankingCustomerId('215703'); |
273
|
|
|
|
274
|
|
|
// Formatted and filled with zeros |
275
|
|
|
$this->assertEquals( |
276
|
|
|
'21 57030 00075 20033 45590 00126', |
277
|
|
|
$this->slipData->getCompleteReferenceNumber() |
278
|
|
|
); |
279
|
|
|
// Not formatted but filled with zeros |
280
|
|
|
$this->assertEquals( |
281
|
|
|
'215703000075200334559000126', |
282
|
|
|
$this->slipData->getCompleteReferenceNumber(false) |
283
|
|
|
); |
284
|
|
|
// Formatted but not filled with zeros |
285
|
|
|
$this->assertEquals( |
286
|
|
|
'21 57030 00075 20033 45590 00126', |
287
|
|
|
$this->slipData->getCompleteReferenceNumber(true, false) |
288
|
|
|
); |
289
|
|
|
// Neither formatted nor filled with zeros |
290
|
|
|
$this->assertEquals( |
291
|
|
|
'215703000075200334559000126', |
292
|
|
|
$this->slipData->getCompleteReferenceNumber(false, false) |
293
|
|
|
); |
294
|
|
|
|
295
|
|
|
// With long banking customer ID with expected 0 filling |
296
|
|
|
$this->slipData->setBankingCustomerId('123456789', 10); |
297
|
|
|
|
298
|
|
|
// Formatted and filled with zeros |
299
|
|
|
$this->assertEquals( |
300
|
|
|
'01 23456 78975 20033 45590 00128', |
301
|
|
|
$this->slipData->getCompleteReferenceNumber() |
302
|
|
|
); |
303
|
|
|
// Not formatted but filled with zeros |
304
|
|
|
$this->assertEquals( |
305
|
|
|
'012345678975200334559000128', |
306
|
|
|
$this->slipData->getCompleteReferenceNumber(false) |
307
|
|
|
); |
308
|
|
|
|
309
|
|
|
// Formatted but not filled with zeros |
310
|
|
|
$this->assertEquals( |
311
|
|
|
'01 23456 78975 20033 45590 00128', |
312
|
|
|
$this->slipData->getCompleteReferenceNumber(true, false) |
313
|
|
|
); |
314
|
|
|
// Neither formatted nor filled with zeros |
315
|
|
|
$this->assertEquals( |
316
|
|
|
'012345678975200334559000128', |
317
|
|
|
$this->slipData->getCompleteReferenceNumber(false, false) |
318
|
|
|
); |
319
|
|
|
|
320
|
|
|
// With long banking customer ID without expected 0 filling |
321
|
|
|
$this->slipData->setBankingCustomerId('1234567', 7); |
322
|
|
|
|
323
|
|
|
// Formatted and filled with zeros |
324
|
|
|
$this->assertEquals( |
325
|
|
|
'12 34567 00075 20033 45590 00128', |
326
|
|
|
$this->slipData->getCompleteReferenceNumber() |
327
|
|
|
); |
328
|
|
|
// Not formatted but filled with zeros |
329
|
|
|
$this->assertEquals( |
330
|
|
|
'123456700075200334559000128', |
331
|
|
|
$this->slipData->getCompleteReferenceNumber(false) |
332
|
|
|
); |
333
|
|
|
|
334
|
|
|
// Formatted but not filled with zeros |
335
|
|
|
$this->assertEquals( |
336
|
|
|
'12 34567 00075 20033 45590 00128', |
337
|
|
|
$this->slipData->getCompleteReferenceNumber(true, false) |
338
|
|
|
); |
339
|
|
|
// Neither formatted nor filled with zeros |
340
|
|
|
$this->assertEquals( |
341
|
|
|
'123456700075200334559000128', |
342
|
|
|
$this->slipData->getCompleteReferenceNumber(false, false) |
343
|
|
|
); |
344
|
|
|
|
345
|
|
|
// Test with reference number but without banking customer ID |
346
|
|
|
$this->slipData->setWithBankingCustomerId(false); |
347
|
|
|
|
348
|
|
|
// Formatted and filled with zeros |
349
|
|
|
$this->assertEquals( |
350
|
|
|
'00 00000 00075 20033 45590 00129', |
351
|
|
|
$this->slipData->getCompleteReferenceNumber() |
352
|
|
|
); |
353
|
|
|
// Not formatted but filled with zeros |
354
|
|
|
$this->assertEquals( |
355
|
|
|
'000000000075200334559000129', |
356
|
|
|
$this->slipData->getCompleteReferenceNumber(false) |
357
|
|
|
); |
358
|
|
|
// Formatted but not filled with zeros |
359
|
|
|
$this->assertEquals( |
360
|
|
|
'75 20033 45590 00129', |
361
|
|
|
$this->slipData->getCompleteReferenceNumber(true, false) |
362
|
|
|
); |
363
|
|
|
// Neither formatted nor filled with zeros |
364
|
|
|
$this->assertEquals( |
365
|
|
|
'75200334559000129', |
366
|
|
|
$this->slipData->getCompleteReferenceNumber(false, false) |
367
|
|
|
); |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
/** |
371
|
|
|
* Tests the getCompleteReferenceNumber method with the reference number disabled |
372
|
|
|
* |
373
|
|
|
* @return void |
374
|
|
|
* @expectedException \SwissPaymentSlip\SwissPaymentSlip\Exception\DisabledDataException |
375
|
|
|
* @expectedExceptionMessage You are accessing the disabled reference number. You need to re-enable it first. |
376
|
|
|
* @covers ::getCompleteReferenceNumber |
377
|
|
|
* @covers ::getReferenceNumber |
378
|
|
|
*/ |
379
|
|
|
public function testGetCompleteReferenceNumberWithReferenceNrDisabled() |
380
|
|
|
{ |
381
|
|
|
$this->slipData->setWithReferenceNumber(false); |
382
|
|
|
$this->slipData->getCompleteReferenceNumber(); |
383
|
|
|
} |
384
|
|
|
|
385
|
|
|
/** |
386
|
|
|
* Tests the getCodeLine method |
387
|
|
|
* |
388
|
|
|
* @return void |
389
|
|
|
* @covers ::getCodeLine |
390
|
|
|
* @covers ::modulo10 |
391
|
|
|
* @covers ::getAccountDigits |
392
|
|
|
*/ |
393
|
|
|
public function testGetCodeLine() |
394
|
|
|
{ |
395
|
|
|
$this->slipData->setAccountNumber('01-145-6'); |
396
|
|
|
$this->slipData->setAmount(2830.50); |
397
|
|
|
$this->slipData->setReferenceNumber('7520033455900012'); |
398
|
|
|
$this->slipData->setBankingCustomerId('215703'); |
399
|
|
|
|
400
|
|
|
// Filled with zeros |
401
|
|
|
$this->assertEquals( |
402
|
|
|
'0100002830509>215703000075200334559000126+ 010001456>', |
403
|
|
|
$this->slipData->getCodeLine() |
404
|
|
|
); |
405
|
|
|
// Not filled with zeros |
406
|
|
|
$this->assertEquals( |
407
|
|
|
'0100002830509>215703000075200334559000126+ 010001456>', |
408
|
|
|
$this->slipData->getCodeLine(false) |
409
|
|
|
); |
410
|
|
|
|
411
|
|
|
$this->slipData->setReferenceNumber('123456789'); |
412
|
|
|
$this->slipData->setBankingCustomerId('1234'); |
413
|
|
|
|
414
|
|
|
// Filled with zeros |
415
|
|
|
$this->assertEquals( |
416
|
|
|
'0100002830509>001234000000000001234567892+ 010001456>', |
417
|
|
|
$this->slipData->getCodeLine() |
418
|
|
|
); |
419
|
|
|
// Not filled with zeros |
420
|
|
|
$this->assertEquals( |
421
|
|
|
'0100002830509>001234000000000001234567892+ 010001456>', |
422
|
|
|
$this->slipData->getCodeLine(false) |
423
|
|
|
); |
424
|
|
|
|
425
|
|
|
// With long banking customer ID with expected 0 filling |
426
|
|
|
$this->slipData->setBankingCustomerId('123456789', 10); |
427
|
|
|
|
428
|
|
|
// Filled with zeros |
429
|
|
|
$this->assertEquals( |
430
|
|
|
'0100002830509>012345678900000001234567891+ 010001456>', |
431
|
|
|
$this->slipData->getCodeLine() |
432
|
|
|
); |
433
|
|
|
// Not filled with zeros |
434
|
|
|
$this->assertEquals( |
435
|
|
|
'0100002830509>012345678900000001234567891+ 010001456>', |
436
|
|
|
$this->slipData->getCodeLine(false) |
437
|
|
|
); |
438
|
|
|
|
439
|
|
|
// With long banking customer ID without expected 0 filling |
440
|
|
|
$this->slipData->setBankingCustomerId('1234567', 7); |
441
|
|
|
|
442
|
|
|
// Filled with zeros |
443
|
|
|
$this->assertEquals( |
444
|
|
|
'0100002830509>123456700000000001234567891+ 010001456>', |
445
|
|
|
$this->slipData->getCodeLine() |
446
|
|
|
); |
447
|
|
|
// Not filled with zeros |
448
|
|
|
$this->assertEquals( |
449
|
|
|
'0100002830509>123456700000000001234567891+ 010001456>', |
450
|
|
|
$this->slipData->getCodeLine(false) |
451
|
|
|
); |
452
|
|
|
|
453
|
|
|
$this->slipData->setWithBankingCustomerId(false); |
454
|
|
|
|
455
|
|
|
// Filled with zeros |
456
|
|
|
$this->assertEquals( |
457
|
|
|
'0100002830509>000000000000000001234567894+ 010001456>', |
458
|
|
|
$this->slipData->getCodeLine() |
459
|
|
|
); |
460
|
|
|
// Not filled with zeros |
461
|
|
|
$this->assertEquals( |
462
|
|
|
'0100002830509>1234567894+ 010001456>', |
463
|
|
|
$this->slipData->getCodeLine(false) |
464
|
|
|
); |
465
|
|
|
|
466
|
|
|
$this->slipData->setAmount(0.0); |
467
|
|
|
|
468
|
|
|
// Filled with zeros |
469
|
|
|
$this->assertEquals( |
470
|
|
|
'0100000000005>000000000000000001234567894+ 010001456>', |
471
|
|
|
$this->slipData->getCodeLine() |
472
|
|
|
); |
473
|
|
|
// Not filled with zeros |
474
|
|
|
$this->assertEquals( |
475
|
|
|
'0100000000005>1234567894+ 010001456>', |
476
|
|
|
$this->slipData->getCodeLine(false) |
477
|
|
|
); |
478
|
|
|
|
479
|
|
|
$this->slipData->setWithAmount(false); |
480
|
|
|
|
481
|
|
|
// Filled with zeros |
482
|
|
|
$this->assertEquals( |
483
|
|
|
'042>000000000000000001234567894+ 010001456>', |
484
|
|
|
$this->slipData->getCodeLine() |
485
|
|
|
); |
486
|
|
|
// Not filled with zeros |
487
|
|
|
$this->assertEquals( |
488
|
|
|
'042>1234567894+ 010001456>', |
489
|
|
|
$this->slipData->getCodeLine(false) |
490
|
|
|
); |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* Tests the setNotForPayment method |
495
|
|
|
* |
496
|
|
|
* @return void |
497
|
|
|
* @covers ::setNotForPayment |
498
|
|
|
* @covers ::appendCheckDigit |
499
|
|
|
* @covers ::getCompleteReferenceNumber |
500
|
|
|
* @covers ::getCodeLine |
501
|
|
|
* @covers ::getAccountDigits |
502
|
|
|
*/ |
503
|
|
|
public function testSetNotForPayment() |
504
|
|
|
{ |
505
|
|
|
$returned = $this->slipData->setNotForPayment(true); |
506
|
|
|
$this->assertInstanceOf('SwissPaymentSlip\SwissPaymentSlip\OrangePaymentSlipData', $returned); |
507
|
|
|
$this->assertTrue($this->slipData->getNotForPayment()); |
508
|
|
|
|
509
|
|
|
$this->assertEquals('XXXXXXXXXXXXXXXXXXXX', $this->slipData->getReferenceNumber()); |
510
|
|
|
$this->assertEquals('XXXXXXXXXXXXXXXXXXXXXXXXXXX', $this->slipData->getCompleteReferenceNumber(false)); |
511
|
|
|
$this->assertEquals('XX XXXXX XXXXX XXXXX XXXXX XXXXX', $this->slipData->getCompleteReferenceNumber()); |
512
|
|
|
|
513
|
|
|
$this->assertEquals('XXXXXXXXXXXXX>XXXXXXXXXXXXXXXXXXXXXXXXXXX+ XXXXXXXXX>', $this->slipData->getCodeLine()); |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
/** |
517
|
|
|
* Tests the setNotForPayment method when fields are disabled |
518
|
|
|
* |
519
|
|
|
* @return void |
520
|
|
|
* @covers ::setNotForPayment |
521
|
|
|
*/ |
522
|
|
|
public function testSetNotForPaymentDisabledFields() |
523
|
|
|
{ |
524
|
|
|
$this->slipData->setWithReferenceNumber(false); |
525
|
|
|
$this->slipData->setWithBankingCustomerId(false); |
526
|
|
|
|
527
|
|
|
$this->slipData->setNotForPayment(true); |
528
|
|
|
} |
529
|
|
|
} |
530
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: