Lines 303-309
subtest "to_api() tests" => sub {
Link Here
|
303 |
is($biblio_api->{items}->[0]->{holds}->[0]->{hold_id}, $hold->reserve_id, 'Hold matches'); |
303 |
is($biblio_api->{items}->[0]->{holds}->[0]->{hold_id}, $hold->reserve_id, 'Hold matches'); |
304 |
is_deeply($biblio_api->{biblioitem}, $biblio->biblioitem->to_api, 'More than one root'); |
304 |
is_deeply($biblio_api->{biblioitem}, $biblio->biblioitem->to_api, 'More than one root'); |
305 |
|
305 |
|
306 |
my $_str = { |
306 |
my $_strings = { |
307 |
location => { |
307 |
location => { |
308 |
category => 'ASD', |
308 |
category => 'ASD', |
309 |
str => 'Estante alto', |
309 |
str => 'Estante alto', |
Lines 311-328
subtest "to_api() tests" => sub {
Link Here
|
311 |
} |
311 |
} |
312 |
}; |
312 |
}; |
313 |
|
313 |
|
314 |
# mock Koha::Item so it implements 'api_av_mapping' |
314 |
# mock Koha::Item so it implements 'api_strings_mapping' |
315 |
my $item_mock = Test::MockModule->new('Koha::Item'); |
315 |
my $item_mock = Test::MockModule->new('Koha::Item'); |
316 |
$item_mock->mock( |
316 |
$item_mock->mock( |
317 |
'api_av_mapping', |
317 |
'api_strings_mapping', |
318 |
sub { |
318 |
sub { |
319 |
return $_str; |
319 |
return $_strings; |
320 |
} |
320 |
} |
321 |
); |
321 |
); |
322 |
|
322 |
|
323 |
my $hold_api = $hold->to_api( |
323 |
my $hold_api = $hold->to_api( |
324 |
{ |
324 |
{ |
325 |
embed => { 'item' => { av_expand => 1 } } |
325 |
embed => { 'item' => { strings => 1 } } |
326 |
} |
326 |
} |
327 |
); |
327 |
); |
328 |
|
328 |
|
Lines 330-337
subtest "to_api() tests" => sub {
Link Here
|
330 |
is( $hold_api->{item}->{item_id}, $item->itemnumber, 'Object embedded correctly' ); |
330 |
is( $hold_api->{item}->{item_id}, $item->itemnumber, 'Object embedded correctly' ); |
331 |
is_deeply( |
331 |
is_deeply( |
332 |
$hold_api->{item}->{_strings}, |
332 |
$hold_api->{item}->{_strings}, |
333 |
$_str, |
333 |
$_strings, |
334 |
'_str correctly added to nested embed' |
334 |
'_strings correctly added to nested embed' |
335 |
); |
335 |
); |
336 |
|
336 |
|
337 |
# biblio with no items |
337 |
# biblio with no items |
Lines 475-481
subtest "to_api() tests" => sub {
Link Here
|
475 |
|
475 |
|
476 |
my $city_mock = Test::MockModule->new('Koha::City'); |
476 |
my $city_mock = Test::MockModule->new('Koha::City'); |
477 |
$city_mock->mock( |
477 |
$city_mock->mock( |
478 |
'api_av_mapping', |
478 |
'api_strings_mapping', |
479 |
sub { |
479 |
sub { |
480 |
my ( $self, $params ) = @_; |
480 |
my ( $self, $params ) = @_; |
481 |
|
481 |
|
Lines 508-518
subtest "to_api() tests" => sub {
Link Here
|
508 |
} |
508 |
} |
509 |
); |
509 |
); |
510 |
|
510 |
|
511 |
my $mobj = $marseille->to_api( { av_expand => 1, public => 1 } ); |
511 |
my $mobj = $marseille->to_api( { strings => 1, public => 1 } ); |
512 |
my $cobj = $cordoba->to_api( { av_expand => 1, public => 0 } ); |
512 |
my $cobj = $cordoba->to_api( { strings => 1, public => 0 } ); |
513 |
|
513 |
|
514 |
ok( exists $mobj->{_strings}, '_str exists for Marseille' ); |
514 |
ok( exists $mobj->{_strings}, '_strings exists for Marseille' ); |
515 |
ok( exists $cobj->{_strings}, '_str exists for Córdoba' ); |
515 |
ok( exists $cobj->{_strings}, '_strings exists for Córdoba' ); |
516 |
|
516 |
|
517 |
is_deeply( |
517 |
is_deeply( |
518 |
$mobj->{_strings}->{country}, |
518 |
$mobj->{_strings}->{country}, |