|
Lines 2-7
Link Here
|
| 2 |
|
2 |
|
| 3 |
# This file is part of Koha. |
3 |
# This file is part of Koha. |
| 4 |
# |
4 |
# |
|
|
5 |
# Copyright 2020 Koha Development team |
| 5 |
# Copyright (C) 2017 Mark Tompsett |
6 |
# Copyright (C) 2017 Mark Tompsett |
| 6 |
# |
7 |
# |
| 7 |
# Koha is free software; you can redistribute it and/or modify it |
8 |
# Koha is free software; you can redistribute it and/or modify it |
|
Lines 19-25
Link Here
|
| 19 |
|
20 |
|
| 20 |
use Modern::Perl; |
21 |
use Modern::Perl; |
| 21 |
|
22 |
|
| 22 |
use Test::More tests => 3; |
23 |
use Test::More tests => 4; |
| 23 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
| 24 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
| 25 |
|
26 |
|
|
Lines 61-75
t::lib::Mocks::mock_userenv({ branchcode => $branch_1 });
Link Here
|
| 61 |
|
62 |
|
| 62 |
my $bibnum = $builder->build_sample_biblio({ frameworkcode => $frameworkcode })->biblionumber; |
63 |
my $bibnum = $builder->build_sample_biblio({ frameworkcode => $frameworkcode })->biblionumber; |
| 63 |
|
64 |
|
| 64 |
# Create a helper item instance for testing |
65 |
my $item = $builder->build_sample_item( |
| 65 |
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( |
66 |
{ library => $branch_1, itype => $itemtype, biblionumber => $bibnum, enumchron => "enum", copynumber => "copynum" } ); |
| 66 |
{ |
67 |
my $itemnumber = $item->itemnumber; |
| 67 |
homebranch => $branch_1, |
|
|
| 68 |
holdingbranch => $branch_1, |
| 69 |
itype => $itemtype |
| 70 |
}, |
| 71 |
$bibnum |
| 72 |
); |
| 73 |
|
68 |
|
| 74 |
# Modify item; setting barcode. |
69 |
# Modify item; setting barcode. |
| 75 |
my $testbarcode = '97531'; |
70 |
my $testbarcode = '97531'; |
|
Lines 98-104
my $dummy_template_values = {
Link Here
|
| 98 |
template_stat => 1, |
93 |
template_stat => 1, |
| 99 |
}; |
94 |
}; |
| 100 |
|
95 |
|
| 101 |
my $label = C4::Labels::Label->new( |
96 |
my $label_info = { |
| 102 |
batch_id => $batch_id, |
97 |
batch_id => $batch_id, |
| 103 |
item_number => $itemnumber, |
98 |
item_number => $itemnumber, |
| 104 |
llx => $llx, |
99 |
llx => $llx, |
|
Lines 115-132
my $label = C4::Labels::Label->new(
Link Here
|
| 115 |
font_size => $layout->get_attr('font_size'), |
110 |
font_size => $layout->get_attr('font_size'), |
| 116 |
callnum_split => $layout->get_attr('callnum_split'), |
111 |
callnum_split => $layout->get_attr('callnum_split'), |
| 117 |
justify => $layout->get_attr('text_justify'), |
112 |
justify => $layout->get_attr('text_justify'), |
| 118 |
format_string => $layout->get_attr('format_string'), |
|
|
| 119 |
text_wrap_cols => $layout->get_text_wrap_cols( |
113 |
text_wrap_cols => $layout->get_text_wrap_cols( |
| 120 |
label_width => $dummy_template_values->{'label_width'}, |
114 |
label_width => $dummy_template_values->{'label_width'}, |
| 121 |
left_text_margin => $dummy_template_values->{'left_text_margin'} |
115 |
left_text_margin => $dummy_template_values->{'left_text_margin'} |
| 122 |
), |
116 |
), |
| 123 |
); |
117 |
}; |
| 124 |
|
118 |
|
|
|
119 |
my $format_string = '100a 245a'; |
| 120 |
my $label = C4::Labels::Label->new(%$label_info, format_string => $format_string); |
| 125 |
my $label_text = $label->create_label(); |
121 |
my $label_text = $label->create_label(); |
| 126 |
ok( defined $label_text, 'Label Text Value defined.' ); |
122 |
ok( defined $label_text, 'Label Text Value defined.' ); |
| 127 |
|
|
|
| 128 |
my $label_csv_data = $label->csv_data(); |
123 |
my $label_csv_data = $label->csv_data(); |
| 129 |
ok( defined $label_csv_data, 'Label CSV Data defined' ); |
124 |
is_deeply( $label_csv_data, |
|
|
125 |
[ sprintf( "%s %s", $item->biblio->author, $item->biblio->title ) ] ); |
| 126 |
|
| 127 |
$format_string = '100a 245a,enumchron copynumber'; |
| 128 |
$label = C4::Labels::Label->new(%$label_info, format_string => $format_string); |
| 129 |
$label_csv_data = $label->csv_data(); |
| 130 |
is_deeply( |
| 131 |
$label_csv_data, |
| 132 |
[ |
| 133 |
sprintf( "%s %s", $item->biblio->author, $item->biblio->title ), |
| 134 |
sprintf( "%s %s", $item->enumchron, $item->copynumber ) |
| 135 |
] |
| 136 |
); |
| 130 |
|
137 |
|
| 131 |
$schema->storage->txn_rollback(); |
138 |
$schema->storage->txn_rollback(); |
| 132 |
|
139 |
|
| 133 |
- |
|
|