From 3e63758e08a1e1b109e6bec6fb641e639fb6cccc Mon Sep 17 00:00:00 2001 From: Thibaud Guillot Date: Fri, 11 Aug 2023 16:22:57 +0200 Subject: [PATCH] Bug 31550: Add unit tests --- t/db_dependent/AuthorisedValues.t | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/AuthorisedValues.t b/t/db_dependent/AuthorisedValues.t index a1bf7b4812..940786e406 100755 --- a/t/db_dependent/AuthorisedValues.t +++ b/t/db_dependent/AuthorisedValues.t @@ -189,7 +189,7 @@ subtest 'search_by_*_field + find_by_koha_field + get_description + authorised_v }; subtest 'find_by_koha_field' => sub { - plan tests => 3; + plan tests => 4; # Test authorised_value = 0 my $av; $av = Koha::AuthorisedValues->find_by_koha_field( { kohafield => 'items.restricted', authorised_value => 0 } ); @@ -200,6 +200,15 @@ subtest 'search_by_*_field + find_by_koha_field + get_description + authorised_v # Test authorised_value = undef => we do not want to retrieve anything $av = Koha::AuthorisedValues->find_by_koha_field( { kohafield => 'items.restricted', authorised_value => undef } ); is( $av, undef, ); + # Test get authorised_value->opac_description if kohafield is in array + my @authorised_kohafields = ( 'location', 'ccode', 'permanent_location', 'notforloan', 'itemlost', 'withdrawn', 'damaged', 'restricted' ); + foreach my $kohafield (@authorised_kohafields) { + $av = Koha::AuthorisedValues->find_by_koha_field( { kohafield => 'items.' . $kohafield, authorised_value => 'location_1' } ); + if ($av) { + is( + $av->opac_description, 'location_1', "items.$kohafield description added correctly" ); + } + } }; subtest 'get_description_by_koha_field' => sub { plan tests => 4; -- 2.30.2