|
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' => sub { |
121 |
subtest 'search_by_*_field + find_by_koha_field' => sub { |
| 122 |
plan tests => 2; |
122 |
plan tests => 3; |
| 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 151-157
subtest 'search_by_*_field' => sub {
Link Here
|
| 151 |
is( $avs->next->authorised_value, 'location_1', ); |
151 |
is( $avs->next->authorised_value, 'location_1', ); |
| 152 |
}; |
152 |
}; |
| 153 |
subtest 'search_by_koha_field' => sub { |
153 |
subtest 'search_by_koha_field' => sub { |
| 154 |
plan tests => 8; |
154 |
plan tests => 3; |
| 155 |
my $avs; |
155 |
my $avs; |
| 156 |
$avs = Koha::AuthorisedValues->search_by_koha_field(); |
156 |
$avs = Koha::AuthorisedValues->search_by_koha_field(); |
| 157 |
is ( $avs, undef ); |
157 |
is ( $avs, undef ); |
|
Lines 159-175
subtest 'search_by_*_field' => sub {
Link Here
|
| 159 |
is( $avs->count, 3, ); |
159 |
is( $avs->count, 3, ); |
| 160 |
is( $avs->next->authorised_value, 'location_1', ); |
160 |
is( $avs->next->authorised_value, 'location_1', ); |
| 161 |
|
161 |
|
|
|
162 |
}; |
| 163 |
subtest 'find_by_koha_field' => sub { |
| 164 |
plan tests => 3; |
| 162 |
# Test authorised_value = 0 |
165 |
# Test authorised_value = 0 |
| 163 |
$avs = Koha::AuthorisedValues->search_by_koha_field( { kohafield => 'items.restricted', authorised_value => 0 } ); |
166 |
my $av; |
| 164 |
is( $avs->count, 1, ); |
167 |
$av = Koha::AuthorisedValues->find_by_koha_field( { kohafield => 'items.restricted', authorised_value => 0 } ); |
| 165 |
is( $avs->next->lib, $av_0->lib, ); |
168 |
is( $av->lib, $av_0->lib, ); |
| 166 |
# Test authorised_value = "" |
169 |
# Test authorised_value = "" |
| 167 |
$avs = Koha::AuthorisedValues->search_by_koha_field( { kohafield => 'items.restricted', authorised_value => '' } ); |
170 |
$av = Koha::AuthorisedValues->find_by_koha_field( { kohafield => 'items.restricted', authorised_value => '' } ); |
| 168 |
is( $avs->count, 1, ); |
171 |
is( $av->lib, $av_empty_string->lib, ); |
| 169 |
is( $avs->next->lib, $av_empty_string->lib, ); |
|
|
| 170 |
# Test authorised_value = undef => we do not want to retrieve anything |
172 |
# Test authorised_value = undef => we do not want to retrieve anything |
| 171 |
$avs = Koha::AuthorisedValues->search_by_koha_field( { kohafield => 'items.restricted', authorised_value => undef } ); |
173 |
$av = Koha::AuthorisedValues->find_by_koha_field( { kohafield => 'items.restricted', authorised_value => undef } ); |
| 172 |
is( $avs->count, 0, ); |
174 |
is( $av, undef, ); |
| 173 |
|
|
|
| 174 |
}; |
175 |
}; |
| 175 |
}; |
176 |
}; |
| 176 |
- |
|
|