Bug 20937: Truncate items for print notices when user has an email
[koha.git] / t / Labels.t
1 #!/usr/bin/perl
2 #
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
17 #
18 # for context, see http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=2691
19
20 use strict;
21 use warnings;
22
23 use C4::ClassSplitRoutine::LCC;
24 use Test::More tests => 11;
25
26 BEGIN {
27     use_ok('C4::Labels::Label');
28 }
29
30 my $format_string = "title, callnumber";
31 my $parsed_fields = C4::Labels::Label::_get_text_fields($format_string);
32 my $expected_fields = [
33     { code => 'title', desc => 'title' }, 
34     { code => 'itemcallnumber', desc => 'itemcallnumber' }, 
35 ];
36 is_deeply($parsed_fields, $expected_fields, '"callnumber" in label layout alias for "itemcallnumber" per bug 5653');
37
38 is(C4::Labels::Label::_check_params(),"0",'test checking parameters');
39
40 my ($llx,$lly,$width,$height) = ( 0, 0, 10, 10 );
41 ok(!defined C4::Labels::Label::_guide_box(),
42         "Test guide box with undefined parameters returns undef");
43 ok(!defined C4::Labels::Label::_guide_box(undef,$lly,$width,$height),
44         "Test guide box with undefined 'x' coordinate returns undef");
45 ok(!defined C4::Labels::Label::_guide_box($llx,undef,$width,$height),
46         "Test guide box with undefined 'y' coordinate returns undef");
47 ok(!defined C4::Labels::Label::_guide_box($llx,$lly,undef,$height),
48         "Test guide box with undefined 'width' returns undef");
49 ok(!defined C4::Labels::Label::_guide_box($llx,$lly,$width,undef),
50         "Test guide box with undefined 'height' returns undef");
51 is(
52     C4::Labels::Label::_guide_box($llx, $lly, $width, $height),
53     'q
54 0.5 w
55 1.0 0.0 0.0  RG
56 1.0 1.0 1.0  rg
57 0 0 10 10 re
58 B
59 Q
60 ',
61     'Return guide box if all four parameters are defined'
62 );
63
64 ok(C4::Labels::Label::_get_text_fields(), 'test getting textx fields');
65
66 is(C4::ClassSplitRoutine::LCC::split_callnumber(),"0", 'test when split LCC is null');