|
Lines 1-54
Link Here
|
| 1 |
#!/usr/bin/perl |
|
|
| 2 |
# |
| 3 |
# Copyright 2020 University of Helsinki |
| 4 |
# |
| 5 |
# This file is part of Koha. |
| 6 |
# |
| 7 |
# Koha is free software; you can redistribute it and/or modify it |
| 8 |
# under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation; either version 3 of the License, or |
| 10 |
# (at your option) any later version. |
| 11 |
# |
| 12 |
# Koha is distributed in the hope that it will be useful, but |
| 13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 19 |
|
| 20 |
use Modern::Perl; |
| 21 |
|
| 22 |
use Test::More tests => 1; |
| 23 |
|
| 24 |
use t::lib::Mocks; |
| 25 |
use t::lib::TestBuilder; |
| 26 |
|
| 27 |
use C4::Biblio qw( GetMarcBiblio ModBiblioMarc ); |
| 28 |
use Koha::Util::Search; |
| 29 |
use MARC::Field; |
| 30 |
|
| 31 |
my $builder = t::lib::TestBuilder->new; |
| 32 |
|
| 33 |
subtest 'get_component_part_query' => sub { |
| 34 |
plan tests => 3; |
| 35 |
|
| 36 |
my $biblio = $builder->build_sample_biblio(); |
| 37 |
my $biblionumber = $biblio->biblionumber; |
| 38 |
my $record = GetMarcBiblio({ biblionumber => $biblionumber }); |
| 39 |
|
| 40 |
t::lib::Mocks::mock_preference( 'UseControlNumber', '0' ); |
| 41 |
is(Koha::Util::Search::get_component_part_query($biblionumber), "Host-item:(Some boring read)", "UseControlNumber disabled"); |
| 42 |
|
| 43 |
t::lib::Mocks::mock_preference( 'UseControlNumber', '1' ); |
| 44 |
my $marc_001_field = MARC::Field->new('001', $biblionumber); |
| 45 |
$record->append_fields($marc_001_field); |
| 46 |
ModBiblioMarc($record, $biblionumber); |
| 47 |
|
| 48 |
is(Koha::Util::Search::get_component_part_query($biblionumber), "rcn:$biblionumber AND (bib-level:a OR bib-level:b)", "UseControlNumber enabled without MarcOrgCode"); |
| 49 |
|
| 50 |
my $marc_003_field = MARC::Field->new('003', 'OSt'); |
| 51 |
$record->append_fields($marc_003_field); |
| 52 |
ModBiblioMarc($record, $biblionumber); |
| 53 |
is(Koha::Util::Search::get_component_part_query($biblionumber), "((rcn:$biblionumber AND cni:OSt) OR rcn:OSt $biblionumber) AND (bib-level:a OR bib-level:b)", "UseControlNumber enabled with MarcOrgCode"); |
| 54 |
}; |