Lines 118-125
is( @categories, 3, 'There should have 2 categories inserted' );
Link Here
|
118 |
is( $categories[0], $av4->category, 'The first category should be correct (ordered by category name)' ); |
118 |
is( $categories[0], $av4->category, 'The first category should be correct (ordered by category name)' ); |
119 |
is( $categories[1], $av1->category, 'The second category should be correct (ordered by category name)' ); |
119 |
is( $categories[1], $av1->category, 'The second category should be correct (ordered by category name)' ); |
120 |
|
120 |
|
121 |
subtest 'search_by_*_field + find_by_koha_field' => sub { |
121 |
subtest 'search_by_*_field + find_by_koha_field + search_for_descriptions' => sub { |
122 |
plan tests => 3; |
122 |
plan tests => 4; |
123 |
my $loc_cat = Koha::AuthorisedValueCategories->find('LOC'); |
123 |
my $loc_cat = Koha::AuthorisedValueCategories->find('LOC'); |
124 |
$loc_cat->delete if $loc_cat; |
124 |
$loc_cat->delete if $loc_cat; |
125 |
my $mss = Koha::MarcSubfieldStructures->search( { tagfield => 952, tagsubfield => 'c', frameworkcode => '' } ); |
125 |
my $mss = Koha::MarcSubfieldStructures->search( { tagfield => 952, tagsubfield => 'c', frameworkcode => '' } ); |
Lines 173-176
subtest 'search_by_*_field + find_by_koha_field' => sub {
Link Here
|
173 |
$av = Koha::AuthorisedValues->find_by_koha_field( { kohafield => 'items.restricted', authorised_value => undef } ); |
173 |
$av = Koha::AuthorisedValues->find_by_koha_field( { kohafield => 'items.restricted', authorised_value => undef } ); |
174 |
is( $av, undef, ); |
174 |
is( $av, undef, ); |
175 |
}; |
175 |
}; |
|
|
176 |
subtest 'get_description_by_koha_field' => sub { |
177 |
plan tests => 3; |
178 |
my $descriptions; |
179 |
|
180 |
# Test authorised_value = 0 |
181 |
$descriptions = Koha::AuthorisedValues->get_description_by_koha_field( |
182 |
{ kohafield => 'items.restricted', authorised_value => 0 } ); |
183 |
is_deeply( $descriptions, |
184 |
{ lib => $av_0->lib, opac_description => $av_0->lib_opac }, |
185 |
); |
186 |
|
187 |
# Test authorised_value = "" |
188 |
$descriptions = Koha::AuthorisedValues->get_description_by_koha_field( |
189 |
{ kohafield => 'items.restricted', authorised_value => '' } ); |
190 |
is_deeply( |
191 |
$descriptions, |
192 |
{ |
193 |
lib => $av_empty_string->lib, |
194 |
opac_description => $av_empty_string->lib_opac |
195 |
}, |
196 |
); |
197 |
|
198 |
# Test authorised_value = undef => we do not want to retrieve anything |
199 |
$descriptions = Koha::AuthorisedValues->get_description_by_koha_field( |
200 |
{ kohafield => 'items.restricted', authorised_value => undef } ); |
201 |
is_deeply( $descriptions, {}, ) ; # This could be arguable, we could return undef instead |
202 |
}; |
176 |
}; |
203 |
}; |
177 |
- |
|
|