From 6124fc8a5445a08975b0dc395b3e9435258a58f3 Mon Sep 17 00:00:00 2001
From: Fridolin Somers <fridolin.somers@biblibre.com>
Date: Tue, 3 Aug 2021 22:11:10 -1000
Subject: [PATCH] Bug 28554: Fix t/db_dependent/AuthorisedValues.t

Fixes where sort on lib breaks the test.

Also removes useless params in search_by_koha_field()

Run prove t/db_dependent/AuthorisedValues.t

Signed-off-by: David Nind <david@davidnind.com>
---
 t/db_dependent/AuthorisedValues.t | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/t/db_dependent/AuthorisedValues.t b/t/db_dependent/AuthorisedValues.t
index 3c22185e33..e16f1faa89 100755
--- a/t/db_dependent/AuthorisedValues.t
+++ b/t/db_dependent/AuthorisedValues.t
@@ -159,9 +159,9 @@ subtest 'search_by_*_field + find_by_koha_field + get_description' => sub {
     Koha::MarcSubfieldStructure->new( { tagfield => 952, tagsubfield => 'c', frameworkcode => 'ACQ', authorised_value => 'TEST', kohafield => 'items.location' } )->store;
     Koha::MarcSubfieldStructure->new( { tagfield => 952, tagsubfield => 'd', frameworkcode => '', authorised_value => 'ANOTHER_4_TESTS', kohafield => 'items.another_field' } )->store;
     Koha::MarcSubfieldStructure->new( { tagfield => 952, tagsubfield => '5', frameworkcode => '', authorised_value => 'restricted_for_testing', kohafield => 'items.restricted' } )->store;
-    Koha::AuthorisedValue->new( { category => 'TEST', authorised_value => 'location_1' } )->store;
-    Koha::AuthorisedValue->new( { category => 'TEST', authorised_value => 'location_2' } )->store;
-    Koha::AuthorisedValue->new( { category => 'TEST', authorised_value => 'location_3' } )->store;
+    Koha::AuthorisedValue->new( { category => 'TEST', authorised_value => 'location_1', lib => 'location_1' } )->store;
+    Koha::AuthorisedValue->new( { category => 'TEST', authorised_value => 'location_2', lib => 'location_2' } )->store;
+    Koha::AuthorisedValue->new( { category => 'TEST', authorised_value => 'location_3', lib => 'location_3' } )->store;
     Koha::AuthorisedValue->new( { category => 'ANOTHER_4_TESTS', authorised_value => 'an_av' } )->store;
     Koha::AuthorisedValue->new( { category => 'ANOTHER_4_TESTS', authorised_value => 'another_av' } )->store;
     subtest 'search_by_marc_field' => sub {
@@ -180,7 +180,7 @@ subtest 'search_by_*_field + find_by_koha_field + get_description' => sub {
         my $avs;
         $avs = Koha::AuthorisedValues->search_by_koha_field();
         is ( $avs, undef );
-        $avs = Koha::AuthorisedValues->search_by_koha_field( { kohafield => 'items.location', tagfield => 952, tagsubfield => 'c' } );
+        $avs = Koha::AuthorisedValues->search_by_koha_field( { kohafield => 'items.location' } );
         is( $avs->count,                  3, );
         is( $avs->next->authorised_value, 'location_1', );
 
@@ -236,15 +236,15 @@ subtest 'search_by_*_field + find_by_koha_field + get_description' => sub {
         is_deeply(
             \@descriptions,
             [
-                {
-                    authorised_value => '',
-                    lib              => $av_empty_string->lib,
-                    opac_description => $av_empty_string->lib_opac
-                },
                 {
                     authorised_value => $av_0->authorised_value,
                     lib              => $av_0->lib,
                     opac_description => $av_0->lib_opac
+                },
+                {
+                    authorised_value => '',
+                    lib              => $av_empty_string->lib,
+                    opac_description => $av_empty_string->lib_opac
                 }
             ],
         );
-- 
2.20.1