Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1bf0cb6e

Von Cem Aydin vor etwa 2 Jahren hinzugefügt

  • ID 1bf0cb6e7e96abcbda8fa02e179ee3d2118c822b
  • Vorgänger 97e3e9cd
  • Nachfolger e9624b9b

Swiss QR-Bill: Tests zu QrBillFunctions.pm

Unterschiede anzeigen:

SL/Helper/QrBillFunctions.pm
262 262

  
263 263
The other functions always return a result.
264 264

  
265
=head1 TESTS
266

  
267
Tests for functions see t/helper/qrbill_functions.t.
268

  
269
Run: C<t/test.pl t/helper/qrbill_functions.t>
270

  
265 271
=head1 AUTHOR
266 272

  
267 273
Cem Aydin E<lt>cem.aydin@gmx.chE<gt>
t/helper/qrbill_functions.t
1
use Test::More tests => 22;
2

  
3
use strict;
4

  
5
use lib 't';
6
use Support::TestSetup;
7

  
8
use_ok('SL::Helper::QrBillFunctions', qw(assemble_ref_number get_ref_number_formatted
9
  get_iban_formatted get_amount_formatted));
10

  
11
Support::TestSetup::login();
12

  
13
# assemble_ref_number returns successfully
14
is_deeply([ assemble_ref_number('123123', 'c1', 'R2022-02') ],
15
          [ '123123000001000000002022027', undef ],
16
          'assemble_ref_number_ok1');
17
is_deeply([ assemble_ref_number('123123', 'c144', 'R5002') ],
18
          [ '123123000144000000000050026', undef ],
19
          'assemble_ref_number_ok2');
20

  
21
# assemble_ref_number returns an error
22
is_deeply([ assemble_ref_number('1231234', 'c1', 'R2022-02') ],
23
          [ undef, $::locale->text('Bank account id number invalid. Must be 6 digits.') ],
24
          'assemble_ref_number_err_bank_account_id_too_long ');
25
is_deeply([ assemble_ref_number('123A12', 'c1', 'R2022-02') ],
26
          [ undef, $::locale->text('Bank account id number invalid. Must be 6 digits.') ],
27
          'assemble_ref_number_err_bank_account_id_with_letter');
28
is_deeply([ assemble_ref_number('123123', 'c1234567', 'R2022-02') ],
29
          [ undef, $::locale->text('Customer number invalid. Must be less then or equal to 6 digits after non-digits removed.') ],
30
          'assemble_ref_number_err_customer_number_too_long');
31
is_deeply([ assemble_ref_number('123123', 'c1', 'R2022-02-5000-3400-5') ],
32
          [ undef, $::locale->text('Invoice number invalid. Must be less then or equal to 14 digits after non-digits removed.') ],
33
          'assemble_ref_number_err_invoice_number_too_long');
34

  
35
is(get_ref_number_formatted('123123000001000000002022027'),
36
   '12 31230 00001 00000 00020 22027',
37
   'get_ref_number_formatted');
38

  
39
is(get_iban_formatted('CH4431999123000889012'),
40
   'CH44 3199 9123 0008 8901 2',
41
   'get_iban_formatted');
42

  
43
is(get_amount_formatted('1000.00'), '1 000.00', 'get_amount_formatted_1000');
44
is(get_amount_formatted('1.20'), '1.20', 'get_amount_formatted_1');
45
is(get_amount_formatted('12.20'), '12.20', 'get_amount_formatted_12');
46
is(get_amount_formatted('980.20'), '980.20', 'get_amount_formatted_980');
47
is(get_amount_formatted('12500.30'), '12 500.30', 'get_amount_formatted_12500');
48
is(get_amount_formatted('125400.22'), '125 400.22', 'get_amount_formatted_125400');
49
is(get_amount_formatted('1255300.30'), '1 255 300.30', 'get_amount_formatted_1255300');
50
is(get_amount_formatted('12553400.30'), '12 553 400.30', 'get_amount_formatted_12553400');
51
is(get_amount_formatted('122.'), undef, 'get_amount_formatted_122err');
52
is(get_amount_formatted('123'), undef, 'get_amount_formatted_123err');
53
is(get_amount_formatted('12,4'), undef, 'get_amount_formatted_124err');
54
is(get_amount_formatted('10 5'), undef, 'get_amount_formatted_105err');
55
is(get_amount_formatted('10a'), undef, 'get_amount_formatted_10aerr');

Auch abrufbar als: Unified diff