|
Lines 17-24
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 73; |
20 |
use Test::More tests => 74; |
| 21 |
use Test::Warn; |
21 |
use Test::Warn; |
|
|
22 |
use Test::MockModule; |
| 23 |
use t::lib::TestBuilder; |
| 24 |
|
| 25 |
use Koha::Database; |
| 22 |
|
26 |
|
| 23 |
$| = 1; |
27 |
$| = 1; |
| 24 |
|
28 |
|
|
Lines 28-33
BEGIN {
Link Here
|
| 28 |
use_ok('C4::Barcodes'); |
32 |
use_ok('C4::Barcodes'); |
| 29 |
} |
33 |
} |
| 30 |
|
34 |
|
|
|
35 |
my $schema = Koha::Database->new->schema; |
| 36 |
$schema->storage->txn_begin; |
| 37 |
|
| 38 |
my $builder = t::lib::TestBuilder->new; |
| 39 |
|
| 40 |
my $dbh = C4::Context->dbh; |
| 41 |
|
| 42 |
subtest 'Test generation of annual barcodes' => sub { |
| 43 |
|
| 44 |
plan tests => 4; |
| 45 |
|
| 46 |
$dbh->do(q|DELETE FROM issues|); |
| 47 |
$dbh->do(q|DELETE FROM items|); |
| 48 |
|
| 49 |
my $barcodeobj; |
| 50 |
|
| 51 |
warning_like { $barcodeobj = C4::Barcodes->new('annual'); } [ qr/No max barcode (.*) found\. Using initial value\./ ], "(annual) Expected complaint regarding no max barcode found"; |
| 52 |
|
| 53 |
my $barcodevalue = $barcodeobj->value(); |
| 54 |
|
| 55 |
my $item_1 = $builder->build({ |
| 56 |
source => 'Item', |
| 57 |
value => { |
| 58 |
barcode => $barcodevalue |
| 59 |
} |
| 60 |
}); |
| 61 |
|
| 62 |
is($barcodevalue,$barcodeobj->db_max(), "(annual) First barcode saved to db is equal to db_max" ); |
| 63 |
|
| 64 |
#This is just setting the value ahead an arbitrary amount before adding a second barcode to db |
| 65 |
$barcodevalue = $barcodeobj->next_value(); |
| 66 |
$barcodevalue = $barcodeobj->next_value($barcodevalue); |
| 67 |
$barcodevalue = $barcodeobj->next_value($barcodevalue); |
| 68 |
$barcodevalue = $barcodeobj->next_value($barcodevalue); |
| 69 |
$barcodevalue = $barcodeobj->next_value($barcodevalue); |
| 70 |
|
| 71 |
my $item_2 = $builder->build({ |
| 72 |
source => 'Item', |
| 73 |
value => { |
| 74 |
barcode => $barcodevalue |
| 75 |
} |
| 76 |
}); |
| 77 |
|
| 78 |
$barcodeobj = C4::Barcodes->new('annual'); |
| 79 |
|
| 80 |
is($barcodevalue,$barcodeobj->db_max(), '(annual) db_max should equal the greatest barcode in the db when more than 1 present'); |
| 81 |
ok($barcodeobj->value() gt $barcodevalue, '(annual) new barcode object should be created with value greater and last value inserted into db'); |
| 82 |
|
| 83 |
$schema->storage->txn_rollback; |
| 84 |
}; |
| 85 |
|
| 86 |
$dbh->do(q|DELETE FROM issues|); |
| 87 |
$dbh->do(q|DELETE FROM items|); |
| 88 |
|
| 31 |
my %thash = ( |
89 |
my %thash = ( |
| 32 |
incremental => [], |
90 |
incremental => [], |
| 33 |
annual => [], |
91 |
annual => [], |
| 34 |
- |
|
|