Lines 1-9
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
use strict; |
3 |
use Modern::Perl; |
4 |
use warnings; |
4 |
use Test::More tests => 73; |
|
|
5 |
use Test::Warn; |
6 |
|
7 |
$| = 1; |
5 |
|
8 |
|
6 |
use Test::More tests => 66; |
|
|
7 |
BEGIN { |
9 |
BEGIN { |
8 |
use FindBin; |
10 |
use FindBin; |
9 |
use lib $FindBin::Bin; |
11 |
use lib $FindBin::Bin; |
Lines 21-32
my ($obj1,$obj2,$format,$value,$initial,$serial,$re,$next,$previous,$temp);
Link Here
|
21 |
my @formats = sort keys %thash; |
23 |
my @formats = sort keys %thash; |
22 |
foreach (@formats) { |
24 |
foreach (@formats) { |
23 |
my $pre = sprintf '(%-12s)', $_; |
25 |
my $pre = sprintf '(%-12s)', $_; |
24 |
ok($obj1 = C4::Barcodes->new($_), "$pre Barcode Creation : new($_)"); |
26 |
if ($_ eq 'EAN13') { |
|
|
27 |
warning_like { $obj1 = C4::Barcodes->new($_); } |
28 |
[ qr/not valid EAN-13 barcode/ ], |
29 |
"$pre Expected complaint regarding $_ not being a valid EAN-13 barcode"; |
30 |
} |
31 |
elsif ($_ eq 'annual') { |
32 |
warning_like { $obj1 = C4::Barcodes->new($_); } |
33 |
[ qr/No max barcode (.*) found\. Using initial value\./ ], |
34 |
"$pre Expected complaint regarding no max barcode found"; |
35 |
} |
36 |
elsif ($_ eq 'hbyymmincr') { |
37 |
warning_like { $obj1 = C4::Barcodes->new($_); } |
38 |
[ qr/No existing hbyymmincr barcodes found\. Reverting to initial value\./ ], |
39 |
"$pre Expected complaint regarding no hbyymmincr barcodes found"; |
40 |
} |
41 |
elsif ($_ eq 'incremental') { |
42 |
$obj1 = C4::Barcodes->new($_); |
43 |
} |
44 |
else { |
45 |
die "This should not happen! ($_)\n"; |
46 |
} |
47 |
ok($obj1, "$pre Barcode Creation : new($_)"); |
25 |
SKIP: { |
48 |
SKIP: { |
26 |
skip "No Object Returned by new($_)", 17 unless $obj1; |
49 |
skip "No Object Returned by new($_)", 17 unless $obj1; |
27 |
ok($_ eq ($format = $obj1->autoBarcode()), "$pre autoBarcode() : " . ($format || 'FAILED') ); |
50 |
ok($_ eq ($format = $obj1->autoBarcode()), "$pre autoBarcode() : " . ($format || 'FAILED') ); |
28 |
ok($initial= $obj1->initial(), "$pre initial() : " . ($initial|| 'FAILED') ); |
51 |
ok($initial= $obj1->initial(), "$pre initial() : " . ($initial|| 'FAILED') ); |
29 |
$temp = $obj1->db_max(); |
52 |
if ($_ eq 'hbyymmincr') { |
|
|
53 |
warning_like { $temp = $obj1->db_max(); } |
54 |
[ qr/No existing hbyymmincr barcodes found\. Reverting to initial value\./ ], |
55 |
"$pre Expected complaint regarding no hbyymmincr barcodes found"; |
56 |
} |
57 |
else { |
58 |
$temp = $obj1->db_max(); |
59 |
} |
30 |
ok($temp = $obj1->max(), "$pre max() : " . ($temp || 'FAILED') ); |
60 |
ok($temp = $obj1->max(), "$pre max() : " . ($temp || 'FAILED') ); |
31 |
ok($value = $obj1->value(), "$pre value() : " . ($value || 'FAILED') ); |
61 |
ok($value = $obj1->value(), "$pre value() : " . ($value || 'FAILED') ); |
32 |
ok($serial = $obj1->serial(), "$pre serial() : " . ($serial || 'FAILED') ); |
62 |
ok($serial = $obj1->serial(), "$pre serial() : " . ($serial || 'FAILED') ); |
Lines 45-56
foreach (@formats) {
Link Here
|
45 |
foreach $format (@formats) { |
75 |
foreach $format (@formats) { |
46 |
my $pre = sprintf '(%-12s)', $format; |
76 |
my $pre = sprintf '(%-12s)', $format; |
47 |
foreach my $testval (@{$thash{ $format }}) { |
77 |
foreach my $testval (@{$thash{ $format }}) { |
48 |
ok($obj1 = C4::Barcodes->new($format,$testval), "$pre Barcode Creation : new('$format','$testval')"); |
|
|
49 |
if ($format eq 'hbyymmincr') { |
78 |
if ($format eq 'hbyymmincr') { |
|
|
79 |
warning_like { $obj1 = C4::Barcodes->new($format,$testval); } |
80 |
[ qr/No existing hbyymmincr barcodes found\. Reverting to initial value\./ ], |
81 |
"$pre Expected complaint regarding no hbyymmincr barcodes found"; |
82 |
ok($obj1, "$pre Barcode Creation : new('$format','$testval')"); |
50 |
$obj2 = $obj1->new(); |
83 |
$obj2 = $obj1->new(); |
51 |
my $branch; |
84 |
my $branch; |
52 |
ok($branch = $obj1->branch(), "$pre branch() : " . ($branch || 'FAILED') ); |
85 |
ok($branch = $obj1->branch(), "$pre branch() : " . ($branch || 'FAILED') ); |
53 |
ok($branch eq $obj2->branch(), "$pre branch extended to derived object : " . ($obj2->branch || 'FAILED')); |
86 |
ok($branch eq $obj2->branch(), "$pre branch extended to derived object : " . ($obj2->branch || 'FAILED')); |
54 |
} |
87 |
} |
|
|
88 |
elsif ($format eq 'EAN13') { |
89 |
warning_like { $obj1 = C4::Barcodes->new($format,$testval) } |
90 |
[ qr/not valid EAN-13 barcode/ ], |
91 |
"$pre Expected complaint regarding $testval not being a valid EAN-13 barcode"; |
92 |
ok($obj1, "$pre Barcode Creation : new('$format','$testval')"); |
93 |
} |
94 |
else { |
95 |
ok($obj1 = C4::Barcodes->new($format,$testval), "$pre Barcode Creation : new('$format','$testval')"); |
96 |
} |
55 |
} |
97 |
} |
56 |
} |
98 |
} |
57 |
- |
|
|