@@ -, +, @@ --- t/db_dependent/Template/Plugin/AuthorisedValues.t | 33 +++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) --- a/t/db_dependent/Template/Plugin/AuthorisedValues.t +++ a/t/db_dependent/Template/Plugin/AuthorisedValues.t @@ -73,7 +73,7 @@ subtest 'GetByCode' => sub { subtest 'GetDescriptionByKohaField' => sub { - plan tests => 4; + plan tests => 7; $schema->storage->txn_begin; @@ -110,24 +110,35 @@ subtest 'GetDescriptionByKohaField' => sub { ); my $av_2 = $builder->build_object( { class => 'Koha::AuthorisedValues', - value => { category => $avc->category_name, lib_opac => undef, lib => undef } + value => { category => $avc->category_name, lib_opac => undef, lib => 'lib' } + } + ); + my $av_3 = $builder->build_object( + { class => 'Koha::AuthorisedValues', + value => { category => $avc->category_name, lib_opac =>undef, lib => undef } } ); - my $non_existent_av = $av_2->authorised_value; - $av_2->delete; + my $non_existent_av = $av_3->authorised_value; + $av_3->delete; my $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( { opac => 1, kohafield => 'dummy.field', authorised_value => $av_1->authorised_value } ); - is( $av, 'lib_opac', 'We requested an existing AV description, for the OPAC' ); - + is( $av, 'lib_opac', 'We requested an existing AV description for the OPAC' ); $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( - { kohafield => 'dummy.field', authorised_value => $av_1->authorised_value } ); - is( $av, 'lib', 'We requested an existing AV description, not for the OPAC' ); - + { opac => 1, kohafield => 'dummy.field', authorised_value => $av_2->authorised_value } ); + is( $av, 'lib', 'We requested an OPAC AV description for the OPAC, return a regular description' ); + $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( + { opac => 1, kohafield => 'dummy.field', authorised_value => $av_3->authorised_value } ); + is( $av, $av_3->authorised_value, 'We requested an non-existing OPAC AV description for the OPAC, return the authorised_value.' ); $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( { opac => 1, kohafield => 'dummy.field', authorised_value => $non_existent_av } ); - is( $av, '', 'We requested a non existing AV description, for the OPAC, return empty string' ); - + is( $av, '', 'We requested a non existing AV description for the OPAC, return empty string' ); + $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( + { kohafield => 'dummy.field', authorised_value => $av_1->authorised_value } ); + is( $av, 'lib', 'We requested an existing AV regular description.' ); + $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( + { kohafield => 'dummy.field', authorised_value => $av_1->authorised_value } ); + is( $av, $av_3->authorised_value, 'We requested an non-existing AV regular description, return the authorised_value.' ); $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( { kohafield => 'dummy.field', authorised_value => $non_existent_av } ); is( $av, '', --