Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 74; |
20 |
use Test::More tests => 75; |
21 |
use Test::Warn; |
21 |
use Test::Warn; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
use t::lib::TestBuilder; |
23 |
use t::lib::TestBuilder; |
Lines 81-86
subtest 'Test generation of annual barcodes from DB values' => sub {
Link Here
|
81 |
$schema->storage->txn_rollback; |
81 |
$schema->storage->txn_rollback; |
82 |
}; |
82 |
}; |
83 |
|
83 |
|
|
|
84 |
subtest 'Test generation of hbyymmincr barcodes from DB values' => sub { |
85 |
|
86 |
plan tests => 5; |
87 |
|
88 |
$schema->storage->txn_begin; |
89 |
$builder->schema->resultset( 'Issue' )->delete_all; |
90 |
$builder->schema->resultset( 'Item' )->delete_all; |
91 |
|
92 |
my $branchcode_1 = "LETTERS"; #NOTE: This barcode type supports only letters in the branchcode |
93 |
my $barcodeobj; |
94 |
|
95 |
warnings_are { $barcodeobj = C4::Barcodes->new('hbyymmincr'); } |
96 |
[ "HBYYMM Barcode created with no branchcode, default is blank", |
97 |
"No existing hbyymmincr barcodes found. Reverting to initial value.", |
98 |
"HBYYMM Barcode was not passed a branch, default is blank"] |
99 |
, "(hbyymmincr) Expected complaint regarding no max barcode found"; |
100 |
|
101 |
|
102 |
warning_like { $barcodeobj = C4::Barcodes->new('hbyymmincr',$branchcode_1); } |
103 |
[ qr/No existing hbyymmincr barcodes found\. Reverting to initial value\./], |
104 |
"(hbyymmincr) Expected complaint regarding no max barcode found"; |
105 |
|
106 |
my $barcodevalue = $barcodeobj->value(); |
107 |
|
108 |
my $item_1 = $builder->build({ |
109 |
source => 'Item', |
110 |
value => { |
111 |
barcode => $barcodevalue |
112 |
} |
113 |
}); |
114 |
|
115 |
is($barcodevalue,$barcodeobj->db_max(), "(hbyymmincr) First barcode saved to db is equal to db_max" ); |
116 |
|
117 |
#This is just setting the value ahead an arbitrary amount before adding a second barcode to db |
118 |
$barcodevalue = $barcodeobj->next_value(); |
119 |
$barcodevalue = $barcodeobj->next_value($barcodevalue); |
120 |
$barcodevalue = $barcodeobj->next_value($barcodevalue); |
121 |
$barcodevalue = $barcodeobj->next_value($barcodevalue); |
122 |
$barcodevalue = $barcodeobj->next_value($barcodevalue); |
123 |
|
124 |
my $item_2 = $builder->build({ |
125 |
source => 'Item', |
126 |
value => { |
127 |
barcode => $barcodevalue |
128 |
} |
129 |
}); |
130 |
|
131 |
$barcodeobj = C4::Barcodes->new('hbyymmincr',$branchcode_1); |
132 |
|
133 |
is($barcodevalue,$barcodeobj->db_max(), '(hbyymmincr) db_max should equal the greatest barcode in the db when more than 1 present'); |
134 |
ok($barcodeobj->value() gt $barcodevalue, '(hbyymmincr) new barcode object should be created with value greater and last value inserted into db'); |
135 |
|
136 |
$schema->storage->txn_rollback; |
137 |
}; |
138 |
|
139 |
|
84 |
$schema->storage->txn_begin; |
140 |
$schema->storage->txn_begin; |
85 |
|
141 |
|
86 |
$builder->schema->resultset( 'Issue' )->delete_all; |
142 |
$builder->schema->resultset( 'Issue' )->delete_all; |
Lines 108-116
foreach (@formats) {
Link Here
|
108 |
"$pre Expected complaint regarding no max barcode found"; |
164 |
"$pre Expected complaint regarding no max barcode found"; |
109 |
} |
165 |
} |
110 |
elsif ($_ eq 'hbyymmincr') { |
166 |
elsif ($_ eq 'hbyymmincr') { |
111 |
warning_like { $obj1 = C4::Barcodes->new($_); } |
167 |
warnings_are { $obj1 = C4::Barcodes->new($_); } |
112 |
[ qr/No existing hbyymmincr barcodes found\. Reverting to initial value\./ ], |
168 |
[ "HBYYMM Barcode created with no branchcode, default is blank", |
113 |
"$pre Expected complaint regarding no hbyymmincr barcodes found"; |
169 |
"No existing hbyymmincr barcodes found. Reverting to initial value.", |
|
|
170 |
"HBYYMM Barcode was not passed a branch, default is blank"] |
171 |
, "$pre Expected complaint regarding no max barcode found"; |
114 |
} |
172 |
} |
115 |
elsif ($_ eq 'incremental') { |
173 |
elsif ($_ eq 'incremental') { |
116 |
$obj1 = C4::Barcodes->new($_); |
174 |
$obj1 = C4::Barcodes->new($_); |
Lines 122-141
foreach (@formats) {
Link Here
|
122 |
SKIP: { |
180 |
SKIP: { |
123 |
skip "No Object Returned by new($_)", 17 unless $obj1; |
181 |
skip "No Object Returned by new($_)", 17 unless $obj1; |
124 |
ok($_ eq ($format = $obj1->autoBarcode()), "$pre autoBarcode() : " . ($format || 'FAILED') ); |
182 |
ok($_ eq ($format = $obj1->autoBarcode()), "$pre autoBarcode() : " . ($format || 'FAILED') ); |
125 |
ok($initial= $obj1->initial(), "$pre initial() : " . ($initial|| 'FAILED') ); |
|
|
126 |
if ($_ eq 'hbyymmincr') { |
183 |
if ($_ eq 'hbyymmincr') { |
127 |
warning_like { $temp = $obj1->db_max(); } |
184 |
warning_like { $initial= $obj1->initial(); } |
128 |
[ qr/No existing hbyymmincr barcodes found\. Reverting to initial value\./ ], |
185 |
[ qr/HBYYMM Barcode was not passed a branch, default is blank/ ] |
129 |
"$pre Expected complaint regarding no hbyymmincr barcodes found"; |
186 |
,"$pre Expected complaint regarding no branch passed when getting initial\n $pre initial() : " . $initial ; |
|
|
187 |
warnings_are { $temp = $obj1->db_max(); } |
188 |
[ "No existing hbyymmincr barcodes found. Reverting to initial value.", |
189 |
"HBYYMM Barcode was not passed a branch, default is blank"] |
190 |
,"$pre Expected complaint regarding no hbyymmincr barcodes found"; |
130 |
} |
191 |
} |
131 |
else { |
192 |
else { |
|
|
193 |
ok($initial= $obj1->initial(), "$pre initial() : " . ($initial|| 'FAILED') ); |
132 |
$temp = $obj1->db_max(); |
194 |
$temp = $obj1->db_max(); |
133 |
} |
195 |
} |
134 |
ok($temp = $obj1->max(), "$pre max() : " . ($temp || 'FAILED') ); |
196 |
ok($temp = $obj1->max(), "$pre max() : " . ($temp || 'FAILED') ); |
135 |
ok($value = $obj1->value(), "$pre value() : " . ($value || 'FAILED') ); |
197 |
ok($value = $obj1->value(), "$pre value() : " . ($value || 'FAILED') ); |
136 |
ok($serial = $obj1->serial(), "$pre serial() : " . ($serial || 'FAILED') ); |
198 |
ok($serial = $obj1->serial(), "$pre serial() : " . ($serial || 'FAILED') ); |
137 |
ok($temp = $obj1->is_max(), "$pre obj1->is_max() [obj1 should currently be max]"); |
199 |
ok($temp = $obj1->is_max(), "$pre obj1->is_max() [obj1 should currently be max]"); |
138 |
ok($obj2 = $obj1->new(), "$pre Barcode Creation : obj2 = obj1->new()"); |
200 |
if ($_ eq 'hbyymmincr') { |
|
|
201 |
warning_like { $obj2 = $obj1->new(); } |
202 |
[ qr/HBYYMM Barcode created with no branchcode, default is blank/ ] |
203 |
,"$pre Expected complaint regarding no branch passed when getting initial\n $pre Barcode Creation : obj2 = obj1->new()" ; |
204 |
} else { |
205 |
ok($obj2 = $obj1->new(), "$pre Barcode Creation : obj2 = obj1->new()"); |
206 |
} |
139 |
ok(not($obj1->is_max()), "$pre obj1->is_max() [obj1 should no longer be max]"); |
207 |
ok(not($obj1->is_max()), "$pre obj1->is_max() [obj1 should no longer be max]"); |
140 |
ok( $obj2->is_max(), "$pre obj2->is_max() [obj2 should currently be max]"); |
208 |
ok( $obj2->is_max(), "$pre obj2->is_max() [obj2 should currently be max]"); |
141 |
ok($obj2->serial == $obj1->serial + 1, "$pre obj2->serial() : " . ($obj2->serial || 'FAILED')); |
209 |
ok($obj2->serial == $obj1->serial + 1, "$pre obj2->serial() : " . ($obj2->serial || 'FAILED')); |
142 |
- |
|
|