3 # This file is part of Koha.
5 # Copyright (C) 2017 Mark Tompsett
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Test
::More tests
=> 3;
23 use t
::lib
::TestBuilder
;
32 use C4
::Labels
::Layout
;
36 use_ok
('C4::Labels::Label');
38 my $database = Koha
::Database
->new();
39 my $schema = $database->schema();
40 $schema->storage->txn_begin();
43 my ( $llx, $lly ) = ( 0, 0 );
44 my $frameworkcode = q{};
47 my $builder = t
::lib
::TestBuilder
->new;
50 my $branch_1 = $builder->build( { source
=> 'Branch' } )->{branchcode
};
53 my $category_1 = $builder->build( { source
=> 'Category' } )->{categorycode
};
57 $builder->build( { source
=> 'Itemtype', value
=> { notforloan
=> undef } } )
60 t
::lib
::Mocks
::mock_userenv
({ branchcode
=> $branch_1 });
62 my $bibnum = $builder->build_sample_biblio({ frameworkcode
=> $frameworkcode })->biblionumber;
64 # Create a helper item instance for testing
65 my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem
(
67 homebranch
=> $branch_1,
68 holdingbranch
=> $branch_1,
74 # Modify item; setting barcode.
75 my $testbarcode = '97531';
76 ModItem
( { barcode
=> $testbarcode }, $bibnum, $itemnumber );
78 my $layout = C4
::Labels
::Layout
->new( layout_name
=> 'TEST' );
80 my $dummy_template_values = {
83 template_code
=> 'Avery 5160 | 1 x 2-5/8',
84 template_desc
=> '3 columns, 10 rows of labels',
89 top_text_margin
=> 0.139,
90 left_text_margin
=> 0.0417,
101 my $label = C4
::Labels
::Label
->new(
102 batch_id
=> $batch_id,
103 item_number
=> $itemnumber,
106 width
=> $dummy_template_values->{'label_width'},
107 height
=> $dummy_template_values->{'label_height'},
108 top_text_margin
=> $dummy_template_values->{'top_text_margin'},
109 left_text_margin
=> $dummy_template_values->{'left_text_margin'},
110 barcode_type
=> $layout->get_attr('barcode_type'),
111 printing_type
=> 'BIB',
112 guidebox
=> $layout->get_attr('guidebox'),
113 oblique_title
=> $layout->get_attr('oblique_title'),
114 font
=> $layout->get_attr('font'),
115 font_size
=> $layout->get_attr('font_size'),
116 callnum_split
=> $layout->get_attr('callnum_split'),
117 justify
=> $layout->get_attr('text_justify'),
118 format_string
=> $layout->get_attr('format_string'),
119 text_wrap_cols
=> $layout->get_text_wrap_cols(
120 label_width
=> $dummy_template_values->{'label_width'},
121 left_text_margin
=> $dummy_template_values->{'left_text_margin'}
125 my $label_text = $label->create_label();
126 ok
( defined $label_text, 'Label Text Value defined.' );
128 my $label_csv_data = $label->csv_data();
129 ok
( defined $label_csv_data, 'Label CSV Data defined' );
131 $schema->storage->txn_rollback();