From 2a620f5f63990b4c6ec295d77485210f29019b94 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 4 Nov 2022 18:07:28 +0000 Subject: [PATCH] Bug 26635: (QA follow-up) Rename key _str to _strings Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- Koha/Object.pm | 2 +- t/db_dependent/Koha/Object.t | 10 +++--- t/db_dependent/Koha/REST/Plugin/Objects.t | 38 +++++++++++------------ 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Koha/Object.pm b/Koha/Object.pm index 187ba00769..fcebdade9a 100644 --- a/Koha/Object.pm +++ b/Koha/Object.pm @@ -605,7 +605,7 @@ sub to_api { } } - $json_object->{_str} = $avs + $json_object->{_strings} = $avs if $av_expand; if ($embeds) { diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t index 47346c5850..fd06f7821d 100755 --- a/t/db_dependent/Koha/Object.t +++ b/t/db_dependent/Koha/Object.t @@ -329,7 +329,7 @@ subtest "to_api() tests" => sub { is( ref($hold_api->{item}), 'HASH', 'Single nested object works correctly' ); is( $hold_api->{item}->{item_id}, $item->itemnumber, 'Object embedded correctly' ); is_deeply( - $hold_api->{item}->{_str}, + $hold_api->{item}->{_strings}, $_str, '_str correctly added to nested embed' ); @@ -511,11 +511,11 @@ subtest "to_api() tests" => sub { my $mobj = $marseille->to_api( { av_expand => 1, public => 1 } ); my $cobj = $cordoba->to_api( { av_expand => 1, public => 0 } ); - ok( exists $mobj->{_str}, '_str exists for Marseille' ); - ok( exists $cobj->{_str}, '_str exists for Córdoba' ); + ok( exists $mobj->{_strings}, '_str exists for Marseille' ); + ok( exists $cobj->{_strings}, '_str exists for Córdoba' ); is_deeply( - $mobj->{_str}->{country}, + $mobj->{_strings}->{country}, { category => $category->category_name, str => $france->lib_opac, @@ -524,7 +524,7 @@ subtest "to_api() tests" => sub { 'Authorised value for country expanded' ); is_deeply( - $cobj->{_str}->{country}, + $cobj->{_strings}->{country}, { category => $category->category_name, str => $argentina->lib, diff --git a/t/db_dependent/Koha/REST/Plugin/Objects.t b/t/db_dependent/Koha/REST/Plugin/Objects.t index eec8e048bc..079f9c77c7 100755 --- a/t/db_dependent/Koha/REST/Plugin/Objects.t +++ b/t/db_dependent/Koha/REST/Plugin/Objects.t @@ -716,21 +716,21 @@ subtest 'objects.find helper with expanded authorised values' => sub { $t->get_ok( '/cities/' . $manuel->id => { 'x-koha-embed' => '+av_expand' } ) ->status_is(200)->json_is( '/name' => 'Manuel' ) - ->json_has('/_str') - ->json_is( '/_str/country/type' => 'av' ) - ->json_is( '/_str/country/category' => $cat->category_name ) - ->json_is( '/_str/country/str' => $ar->lib ); + ->json_has('/_strings') + ->json_is( '/_strings/country/type' => 'av' ) + ->json_is( '/_strings/country/category' => $cat->category_name ) + ->json_is( '/_strings/country/str' => $ar->lib ); $t->get_ok( '/cities/' . $manuel->id => { 'x-koha-embed' => '' } ) ->status_is(200)->json_is( '/name' => 'Manuel' ) - ->json_hasnt('/_str'); + ->json_hasnt('/_strings'); $t->get_ok( '/cities/' . $manuela->id => { 'x-koha-embed' => '+av_expand' } ) ->status_is(200)->json_is( '/name' => 'Manuela' ) - ->json_has('/_str') - ->json_is( '/_str/country/type' => 'av' ) - ->json_is( '/_str/country/category' => $cat->category_name ) - ->json_is( '/_str/country/str' => $us->lib ); + ->json_has('/_strings') + ->json_is( '/_strings/country/type' => 'av' ) + ->json_is( '/_strings/country/category' => $cat->category_name ) + ->json_is( '/_strings/country/str' => $us->lib ); $schema->storage->txn_rollback; }; @@ -832,20 +832,20 @@ subtest 'objects.search helper with expanded authorised values' => sub { { 'x-koha-embed' => '+av_expand' } )->status_is(200) ->json_has('/0')->json_has('/1')->json_hasnt('/2') ->json_is( '/0/name' => 'Manuel' ) - ->json_has('/0/_str') - ->json_is( '/0/_str/country/str' => $ar->lib ) - ->json_is( '/0/_str/country/type' => 'av' ) - ->json_is( '/0/_str/country/category' => $cat->category_name ) + ->json_has('/0/_strings') + ->json_is( '/0/_strings/country/str' => $ar->lib ) + ->json_is( '/0/_strings/country/type' => 'av' ) + ->json_is( '/0/_strings/country/category' => $cat->category_name ) ->json_is( '/1/name' => 'Manuela' ) - ->json_has('/1/_str') - ->json_is( '/1/_str/country/str' => $us->lib ) - ->json_is( '/1/_str/country/type' => 'av' ) - ->json_is( '/1/_str/country/category' => $cat->category_name ); + ->json_has('/1/_strings') + ->json_is( '/1/_strings/country/str' => $us->lib ) + ->json_is( '/1/_strings/country/type' => 'av' ) + ->json_is( '/1/_strings/country/category' => $cat->category_name ); $t->get_ok( '/cities?name=manuel&_per_page=4&_page=1&_match=starts_with' )->status_is(200) ->json_has('/0')->json_has('/1')->json_hasnt('/2') - ->json_is( '/0/name' => 'Manuel' )->json_hasnt('/0/_str') - ->json_is( '/1/name' => 'Manuela' )->json_hasnt('/1/_str'); + ->json_is( '/0/name' => 'Manuel' )->json_hasnt('/0/_strings') + ->json_is( '/1/name' => 'Manuela' )->json_hasnt('/1/_strings'); $schema->storage->txn_rollback; -- 2.39.5