Lines 1-34
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
4 |
use Test::More tests => 10; |
4 |
use Test::More tests => 7; |
5 |
use Test::MockModule; |
5 |
use Test::MockModule; |
|
|
6 |
use t::lib::TestBuilder; |
6 |
|
7 |
|
7 |
BEGIN { |
8 |
BEGIN { |
8 |
use_ok('C4::Barcodes::ValueBuilder'); |
9 |
use_ok('C4::Barcodes::ValueBuilder'); |
9 |
} |
10 |
}; |
10 |
|
11 |
|
11 |
use Test::DBIx::Class { |
12 |
my $builder = t::lib::TestBuilder->new; |
12 |
schema_class => 'Koha::Schema', |
13 |
my $dbh = C4::Context->dbh; |
13 |
connect_info => ['dbi:SQLite:dbname=:memory:','',''], |
14 |
$dbh->do(q|DELETE FROM items|); |
14 |
connect_opts => { name_sep => '.', quote_char => '`', }, |
15 |
my $item_1 = $builder->build({ |
15 |
fixture_class => '::Populate', |
16 |
source => 'Item', |
16 |
}, 'Biblio' ; |
17 |
value => { |
17 |
|
18 |
barcode => '33333074344563' |
18 |
sub fixtures { |
19 |
} |
19 |
my ( $data ) = @_; |
20 |
}); |
20 |
fixtures_ok [ |
21 |
my $item_2 = $builder->build({ |
21 |
Item => [ |
22 |
source => 'Item', |
22 |
@$data |
23 |
value => { |
23 |
], |
24 |
barcode => 'hb12070890' |
24 |
], 'add fixtures'; |
25 |
} |
25 |
} |
26 |
}); |
26 |
|
27 |
my $item_3 = $builder->build({ |
27 |
my $db = Test::MockModule->new('Koha::Database'); |
28 |
source => 'Item', |
28 |
$db->mock( |
29 |
value => { |
29 |
_new_schema => sub { return Schema(); } |
30 |
barcode => '2012-0034' |
30 |
); |
31 |
} |
31 |
|
32 |
}); |
32 |
|
33 |
|
33 |
my %args = ( |
34 |
my %args = ( |
34 |
year => '2012', |
35 |
year => '2012', |
Lines 40-68
my %args = (
Link Here
|
40 |
locsubfield => 'a' |
41 |
locsubfield => 'a' |
41 |
); |
42 |
); |
42 |
|
43 |
|
43 |
fixtures([ |
|
|
44 |
[ qw/ itemnumber barcode / ], |
45 |
[ 1, 33333074344563 ] |
46 |
]); |
47 |
my ($nextnum, $scr) = C4::Barcodes::ValueBuilder::incremental::get_barcode(\%args); |
44 |
my ($nextnum, $scr) = C4::Barcodes::ValueBuilder::incremental::get_barcode(\%args); |
48 |
is($nextnum, 33333074344564, 'incremental barcode'); |
45 |
is($nextnum, 33333074344564, 'incremental barcode'); |
49 |
is($scr, undef, 'incremental javascript'); |
46 |
is($scr, undef, 'incremental javascript'); |
50 |
|
47 |
|
51 |
fixtures([ |
|
|
52 |
['barcode'], |
53 |
['890'], |
54 |
]); |
55 |
|
56 |
($nextnum, $scr) = C4::Barcodes::ValueBuilder::hbyymmincr::get_barcode(\%args); |
48 |
($nextnum, $scr) = C4::Barcodes::ValueBuilder::hbyymmincr::get_barcode(\%args); |
57 |
is($nextnum, '12070891', 'hbyymmincr barcode'); |
49 |
is($nextnum, '12070891', 'hbyymmincr barcode'); |
58 |
ok(length($scr) > 0, 'hbyymmincr javascript'); |
50 |
ok(length($scr) > 0, 'hbyymmincr javascript'); |
59 |
|
51 |
|
60 |
fixtures([ |
|
|
61 |
['barcode'], |
62 |
#max(cast( substring_index(barcode, \'-\',-1) as signed))'], |
63 |
['34'], |
64 |
]); |
65 |
|
66 |
($nextnum, $scr) = C4::Barcodes::ValueBuilder::annual::get_barcode(\%args); |
52 |
($nextnum, $scr) = C4::Barcodes::ValueBuilder::annual::get_barcode(\%args); |
67 |
is($nextnum, '2012-0035', 'annual barcode'); |
53 |
is($nextnum, '2012-0035', 'annual barcode'); |
68 |
is($scr, undef, 'annual javascript'); |
54 |
is($scr, undef, 'annual javascript'); |
69 |
- |
|
|