|
Lines 21-27
Link Here
|
| 21 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
21 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 22 |
|
22 |
|
| 23 |
use Modern::Perl; |
23 |
use Modern::Perl; |
| 24 |
use Test::More tests => 13; |
24 |
use Test::More tests => 14; |
| 25 |
use Test::Exception; |
25 |
use Test::Exception; |
| 26 |
use Test::MockObject; |
26 |
use Test::MockObject; |
| 27 |
use Test::MockModule; |
27 |
use Test::MockModule; |
|
Lines 230-235
subtest "Test build_additional_item_fields_string" => sub {
Link Here
|
| 230 |
$schema->storage->txn_rollback; |
230 |
$schema->storage->txn_rollback; |
| 231 |
}; |
231 |
}; |
| 232 |
|
232 |
|
|
|
233 |
subtest "Test build_custom_field_string" => sub { |
| 234 |
my $schema = Koha::Database->new->schema; |
| 235 |
$schema->storage->txn_begin; |
| 236 |
|
| 237 |
plan tests => 2; |
| 238 |
|
| 239 |
my $builder = t::lib::TestBuilder->new(); |
| 240 |
|
| 241 |
my $item = $builder->build_sample_item; |
| 242 |
my $item_id = $item->id; |
| 243 |
my $item_barcode = $item->barcode; |
| 244 |
my $ils_item = C4::SIP::ILS::Item->new( $item->barcode ); |
| 245 |
|
| 246 |
my $server = {}; |
| 247 |
$server->{account}->{custom_item_field}->{field} = "XY"; |
| 248 |
$server->{account}->{custom_item_field}->{template} = "[% item.id %] [% item.barcode %], woo!"; |
| 249 |
my $attribute_string = $ils_item->build_additional_item_fields_string( $server ); |
| 250 |
is( $attribute_string, "XY$item_id $item_barcode, woo!|", 'Attribute field generated correctly with single param' ); |
| 251 |
|
| 252 |
$server = {}; |
| 253 |
$server->{account}->{custom_item_field}->[0]->{field} = "ZY"; |
| 254 |
$server->{account}->{custom_item_field}->[0]->{template} = "[% item.id %]!"; |
| 255 |
$server->{account}->{custom_item_field}->[1]->{field} = "ZX"; |
| 256 |
$server->{account}->{custom_item_field}->[1]->{template} = "[% item.barcode %]*"; |
| 257 |
$attribute_string = $ils_item->build_additional_item_fields_string( $server ); |
| 258 |
is( $attribute_string, sprintf("ZY%s!|ZX%s*|", $item_id, $item_barcode), 'Attribute field generated correctly with multiple params' ); |
| 259 |
|
| 260 |
$schema->storage->txn_rollback; |
| 261 |
}; |
| 262 |
|
| 233 |
subtest "Test cr_item_field" => sub { |
263 |
subtest "Test cr_item_field" => sub { |
| 234 |
plan tests => 2; |
264 |
plan tests => 2; |
| 235 |
|
265 |
|
| 236 |
- |
|
|