Bug 21716: Escape publisher in item search
[koha.git] / t / db_dependent / Barcodes_ValueBuilder.t
blob7573bbd0da6bf097a4c8591865ac9840654a55e4
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3 of the License, or (at your option) any later
8 # version.
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, see <http://www.gnu.org/licenses>.
17 use Modern::Perl;
19 use Test::More tests => 7;
20 use Test::MockModule;
21 use t::lib::TestBuilder;
23 use Koha::Database;
25 BEGIN {
26 use_ok('C4::Barcodes::ValueBuilder');
29 my $schema = Koha::Database->new->schema;
30 $schema->storage->txn_begin;
32 my $builder = t::lib::TestBuilder->new;
34 my $dbh = C4::Context->dbh;
35 $dbh->do(q|DELETE FROM issues|);
36 $dbh->do(q|DELETE FROM items|);
37 my $item_1 = $builder->build({
38 source => 'Item',
39 value => {
40 barcode => '33333074344563'
42 });
43 my $item_2 = $builder->build({
44 source => 'Item',
45 value => {
46 barcode => 'hb12070890'
48 });
49 my $item_3 = $builder->build({
50 source => 'Item',
51 value => {
52 barcode => '201200345'
54 });
55 my $item_4 = $builder->build({
56 source => 'Item',
57 value => {
58 barcode => '2012-0034'
60 });
62 my %args = (
63 year => '2012',
64 mon => '07',
65 day => '30',
66 tag => '952',
67 subfield => 'p',
68 loctag => '952',
69 locsubfield => 'a'
72 my ($nextnum, $scr) = C4::Barcodes::ValueBuilder::incremental::get_barcode(\%args);
73 is($nextnum, 33333074344564, 'incremental barcode');
74 is($scr, undef, 'incremental javascript');
76 ($nextnum, $scr) = C4::Barcodes::ValueBuilder::hbyymmincr::get_barcode(\%args);
77 is($nextnum, '12070891', 'hbyymmincr barcode');
78 ok(length($scr) > 0, 'hbyymmincr javascript');
80 ($nextnum, $scr) = C4::Barcodes::ValueBuilder::annual::get_barcode(\%args);
81 is($nextnum, '2012-0035', 'annual barcode');
82 is($scr, undef, 'annual javascript');
84 $schema->storage->txn_rollback;