|
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 84-89
subtest 'Test generation of annual barcodes from DB values' => sub {
Link Here
|
| 84 |
}; |
84 |
}; |
| 85 |
|
85 |
|
| 86 |
|
86 |
|
|
|
87 |
$schema->storage->txn_begin; |
| 88 |
subtest 'Test generation of hbyymmincr barcodes from DB values' => sub { |
| 89 |
|
| 90 |
plan tests => 5; |
| 91 |
|
| 92 |
$builder->schema->resultset( 'Issue' )->delete_all; |
| 93 |
$builder->schema->resultset( 'Item' )->delete_all; |
| 94 |
|
| 95 |
my$barcode_branch = $builder->build({ |
| 96 |
source => 'Branch', |
| 97 |
branchcode => 'LETTERS', |
| 98 |
}); |
| 99 |
|
| 100 |
my $branchcode_1 = "LETT"; |
| 101 |
print "$branchcode_1\n"; |
| 102 |
my $barcodeobj; |
| 103 |
|
| 104 |
warnings_are { $barcodeobj = C4::Barcodes->new('hbyymmincr'); } |
| 105 |
[ "HBYYMM Barcode created with no branchcode, default is blank", |
| 106 |
"No existing hbyymmincr barcodes found. Reverting to initial value.", |
| 107 |
"HBYYMM Barcode was not passed a branch, default is blank"] |
| 108 |
, "(hbyymmincr) Expected complaint regarding no max barcode found"; |
| 109 |
|
| 110 |
|
| 111 |
warning_like { $barcodeobj = C4::Barcodes->new('hbyymmincr',$branchcode_1); } |
| 112 |
[ qr/No existing hbyymmincr barcodes found\. Reverting to initial value\./], |
| 113 |
"(hbyymmincr) Expected complaint regarding no max barcode found"; |
| 114 |
|
| 115 |
my $barcodevalue = $barcodeobj->value(); |
| 116 |
|
| 117 |
my $item_1 = $builder->build({ |
| 118 |
source => 'Item', |
| 119 |
value => { |
| 120 |
barcode => $barcodevalue |
| 121 |
} |
| 122 |
}); |
| 123 |
|
| 124 |
is($barcodevalue,$barcodeobj->db_max(), "(hbyymmincr) First barcode saved to db is equal to db_max" ); |
| 125 |
|
| 126 |
#This is just setting the value ahead an arbitrary amount before adding a second barcode to db |
| 127 |
$barcodevalue = $barcodeobj->next_value(); |
| 128 |
$barcodevalue = $barcodeobj->next_value($barcodevalue); |
| 129 |
$barcodevalue = $barcodeobj->next_value($barcodevalue); |
| 130 |
$barcodevalue = $barcodeobj->next_value($barcodevalue); |
| 131 |
$barcodevalue = $barcodeobj->next_value($barcodevalue); |
| 132 |
|
| 133 |
my $item_2 = $builder->build({ |
| 134 |
source => 'Item', |
| 135 |
value => { |
| 136 |
barcode => $barcodevalue |
| 137 |
} |
| 138 |
}); |
| 139 |
|
| 140 |
$barcodeobj = C4::Barcodes->new('hbyymmincr',$branchcode_1); |
| 141 |
|
| 142 |
is($barcodevalue,$barcodeobj->db_max(), '(hbyymmincr) db_max should equal the greatest barcode in the db when more than 1 present'); |
| 143 |
ok($barcodeobj->value() gt $barcodevalue, '(hbyymmincr) new barcode object should be created with value greater and last value inserted into db'); |
| 144 |
|
| 145 |
$schema->storage->txn_rollback; |
| 146 |
}; |
| 147 |
|
| 87 |
$builder->schema->resultset( 'Issue' )->delete_all; |
148 |
$builder->schema->resultset( 'Issue' )->delete_all; |
| 88 |
$builder->schema->resultset( 'Item' )->delete_all; |
149 |
$builder->schema->resultset( 'Item' )->delete_all; |
| 89 |
|
150 |
|
|
Lines 109-117
foreach (@formats) {
Link Here
|
| 109 |
"$pre Expected complaint regarding no max barcode found"; |
170 |
"$pre Expected complaint regarding no max barcode found"; |
| 110 |
} |
171 |
} |
| 111 |
elsif ($_ eq 'hbyymmincr') { |
172 |
elsif ($_ eq 'hbyymmincr') { |
| 112 |
warning_like { $obj1 = C4::Barcodes->new($_); } |
173 |
warnings_are { $obj1 = C4::Barcodes->new($_); } |
| 113 |
[ qr/No existing hbyymmincr barcodes found\. Reverting to initial value\./ ], |
174 |
[ "HBYYMM Barcode created with no branchcode, default is blank", |
| 114 |
"$pre Expected complaint regarding no hbyymmincr barcodes found"; |
175 |
"No existing hbyymmincr barcodes found. Reverting to initial value.", |
|
|
176 |
"HBYYMM Barcode was not passed a branch, default is blank"] |
| 177 |
, "$pre Expected complaint regarding no max barcode found"; |
| 115 |
} |
178 |
} |
| 116 |
elsif ($_ eq 'incremental') { |
179 |
elsif ($_ eq 'incremental') { |
| 117 |
$obj1 = C4::Barcodes->new($_); |
180 |
$obj1 = C4::Barcodes->new($_); |
|
Lines 123-142
foreach (@formats) {
Link Here
|
| 123 |
SKIP: { |
186 |
SKIP: { |
| 124 |
skip "No Object Returned by new($_)", 17 unless $obj1; |
187 |
skip "No Object Returned by new($_)", 17 unless $obj1; |
| 125 |
ok($_ eq ($format = $obj1->autoBarcode()), "$pre autoBarcode() : " . ($format || 'FAILED') ); |
188 |
ok($_ eq ($format = $obj1->autoBarcode()), "$pre autoBarcode() : " . ($format || 'FAILED') ); |
| 126 |
ok($initial= $obj1->initial(), "$pre initial() : " . ($initial|| 'FAILED') ); |
189 |
# ok($initial= $obj1->initial(), "$pre initial() : " . ($initial|| 'FAILED') ); |
| 127 |
if ($_ eq 'hbyymmincr') { |
190 |
if ($_ eq 'hbyymmincr') { |
| 128 |
warning_like { $temp = $obj1->db_max(); } |
191 |
warning_like { $initial= $obj1->initial(); } |
| 129 |
[ qr/No existing hbyymmincr barcodes found\. Reverting to initial value\./ ], |
192 |
[ qr/HBYYMM Barcode was not passed a branch, default is blank/ ] |
| 130 |
"$pre Expected complaint regarding no hbyymmincr barcodes found"; |
193 |
,"$pre Expected complaint regarding no branch passed when getting initial\n $pre initial() : " . $initial ; |
|
|
194 |
warnings_are { $temp = $obj1->db_max(); } |
| 195 |
[ "No existing hbyymmincr barcodes found. Reverting to initial value.", |
| 196 |
"HBYYMM Barcode was not passed a branch, default is blank"] |
| 197 |
,"$pre Expected complaint regarding no hbyymmincr barcodes found"; |
| 131 |
} |
198 |
} |
| 132 |
else { |
199 |
else { |
|
|
200 |
ok($initial= $obj1->initial(), "$pre initial() : " . ($initial|| 'FAILED') ); |
| 133 |
$temp = $obj1->db_max(); |
201 |
$temp = $obj1->db_max(); |
| 134 |
} |
202 |
} |
| 135 |
ok($temp = $obj1->max(), "$pre max() : " . ($temp || 'FAILED') ); |
203 |
ok($temp = $obj1->max(), "$pre max() : " . ($temp || 'FAILED') ); |
| 136 |
ok($value = $obj1->value(), "$pre value() : " . ($value || 'FAILED') ); |
204 |
ok($value = $obj1->value(), "$pre value() : " . ($value || 'FAILED') ); |
| 137 |
ok($serial = $obj1->serial(), "$pre serial() : " . ($serial || 'FAILED') ); |
205 |
ok($serial = $obj1->serial(), "$pre serial() : " . ($serial || 'FAILED') ); |
| 138 |
ok($temp = $obj1->is_max(), "$pre obj1->is_max() [obj1 should currently be max]"); |
206 |
ok($temp = $obj1->is_max(), "$pre obj1->is_max() [obj1 should currently be max]"); |
| 139 |
ok($obj2 = $obj1->new(), "$pre Barcode Creation : obj2 = obj1->new()"); |
207 |
if ($_ eq 'hbyymmincr') { |
|
|
208 |
warning_like { $obj2 = $obj1->new(); } |
| 209 |
[ qr/HBYYMM Barcode created with no branchcode, default is blank/ ] |
| 210 |
,"$pre Expected complaint regarding no branch passed when getting initial\n $pre Barcode Creation : obj2 = obj1->new()" ; |
| 211 |
} else { |
| 212 |
ok($obj2 = $obj1->new(), "$pre Barcode Creation : obj2 = obj1->new()"); |
| 213 |
} |
| 140 |
ok(not($obj1->is_max()), "$pre obj1->is_max() [obj1 should no longer be max]"); |
214 |
ok(not($obj1->is_max()), "$pre obj1->is_max() [obj1 should no longer be max]"); |
| 141 |
ok( $obj2->is_max(), "$pre obj2->is_max() [obj2 should currently be max]"); |
215 |
ok( $obj2->is_max(), "$pre obj2->is_max() [obj2 should currently be max]"); |
| 142 |
ok($obj2->serial == $obj1->serial + 1, "$pre obj2->serial() : " . ($obj2->serial || 'FAILED')); |
216 |
ok($obj2->serial == $obj1->serial + 1, "$pre obj2->serial() : " . ($obj2->serial || 'FAILED')); |
| 143 |
- |
|
|