Lines 285-293
subtest 'prepare_cgi_additional_field_values' => sub {
Link Here
|
285 |
|
285 |
|
286 |
subtest 'strings_map() tests' => sub { |
286 |
subtest 'strings_map() tests' => sub { |
287 |
plan tests => 1; |
287 |
plan tests => 1; |
288 |
$schema->txn_begin; |
288 |
$schema->txn_begin; |
289 |
Koha::AdditionalFields->search->delete; |
289 |
Koha::AdditionalFields->search->delete; |
290 |
my $license = Koha::ERM::License->new( |
290 |
my $license = Koha::ERM::License->new( |
291 |
{ |
291 |
{ |
292 |
name => "license name", |
292 |
name => "license name", |
293 |
type => "national", |
293 |
type => "national", |
Lines 296-302
subtest 'strings_map() tests' => sub {
Link Here
|
296 |
} |
296 |
} |
297 |
); |
297 |
); |
298 |
$license->store()->discard_changes(); |
298 |
$license->store()->discard_changes(); |
299 |
my $field = Koha::AdditionalField->new( |
299 |
my $field = Koha::AdditionalField->new( |
300 |
{ |
300 |
{ |
301 |
tablename => 'erm_licenses', |
301 |
tablename => 'erm_licenses', |
302 |
name => 'af_1', |
302 |
name => 'af_1', |
Lines 304-310
subtest 'strings_map() tests' => sub {
Link Here
|
304 |
} |
304 |
} |
305 |
); |
305 |
); |
306 |
$field->store()->discard_changes(); |
306 |
$field->store()->discard_changes(); |
307 |
my $field2 = Koha::AdditionalField->new( |
307 |
my $field2 = Koha::AdditionalField->new( |
308 |
{ |
308 |
{ |
309 |
tablename => 'erm_licenses', |
309 |
tablename => 'erm_licenses', |
310 |
name => 'af_2', |
310 |
name => 'af_2', |
Lines 312-318
subtest 'strings_map() tests' => sub {
Link Here
|
312 |
} |
312 |
} |
313 |
); |
313 |
); |
314 |
$field2->store()->discard_changes(); |
314 |
$field2->store()->discard_changes(); |
315 |
my $value = 'some license value'; |
315 |
my $value = 'some license value'; |
316 |
$license->set_additional_fields( |
316 |
$license->set_additional_fields( |
317 |
[ |
317 |
[ |
318 |
{ |
318 |
{ |
Lines 327-349
subtest 'strings_map() tests' => sub {
Link Here
|
327 |
} |
327 |
} |
328 |
] |
328 |
] |
329 |
); |
329 |
); |
330 |
$license->add_additional_fields( |
330 |
$license->add_additional_fields( |
331 |
{ |
331 |
{ |
332 |
$field2->id => ['second field'], |
332 |
$field2->id => ['second field'], |
333 |
|
333 |
|
334 |
}, |
334 |
}, |
335 |
'erm_licenses' |
335 |
'erm_licenses' |
336 |
); |
336 |
); |
337 |
my $av_category = Koha::AuthorisedValueCategory->new( { category_name => "AV_CAT_NAME" } ); |
337 |
my $av_category = Koha::AuthorisedValueCategory->new( { category_name => "AV_CAT_NAME" } ); |
338 |
$av_category->store()->discard_changes(); |
338 |
$av_category->store()->discard_changes(); |
339 |
my $av_value = Koha::AuthorisedValue->new( |
339 |
my $av_value = Koha::AuthorisedValue->new( |
340 |
{ |
340 |
{ |
341 |
category => $av_category->category_name, |
341 |
category => $av_category->category_name, |
342 |
authorised_value => 'BOB', |
342 |
authorised_value => 'BOB', |
343 |
lib => "Robert" |
343 |
lib => "Robert" |
344 |
} |
344 |
} |
345 |
); |
345 |
); |
346 |
my $av_field = Koha::AdditionalField->new( |
346 |
my $av_field = Koha::AdditionalField->new( |
347 |
{ |
347 |
{ |
348 |
tablename => "erm_licenses", |
348 |
tablename => "erm_licenses", |
349 |
name => "av_field", |
349 |
name => "av_field", |
Lines 352-366
subtest 'strings_map() tests' => sub {
Link Here
|
352 |
} |
352 |
} |
353 |
); |
353 |
); |
354 |
$av_field->store()->discard_changes(); |
354 |
$av_field->store()->discard_changes(); |
355 |
$license->add_additional_fields( |
355 |
$license->add_additional_fields( |
356 |
{ |
356 |
{ |
357 |
$av_field->id => [ $av_value->authorised_value ], |
357 |
$av_field->id => [ $av_value->authorised_value ], |
358 |
|
358 |
|
359 |
}, |
359 |
}, |
360 |
'erm_licenses' |
360 |
'erm_licenses' |
361 |
); |
361 |
); |
362 |
my $values = $license->get_additional_field_values_for_template; |
362 |
my $values = $license->get_additional_field_values_for_template; |
363 |
my $strings_map = $license->strings_map; |
363 |
my $strings_map = $license->strings_map; |
364 |
is_deeply( |
364 |
is_deeply( |
365 |
$strings_map, |
365 |
$strings_map, |
366 |
{ |
366 |
{ |
Lines 387-392
subtest 'strings_map() tests' => sub {
Link Here
|
387 |
}, |
387 |
}, |
388 |
'strings_map looks good' |
388 |
'strings_map looks good' |
389 |
); |
389 |
); |
390 |
$schema->txn_rollback; |
390 |
$schema->txn_rollback; |
391 |
; |
391 |
|
392 |
}; |
392 |
}; |
393 |
- |
|
|