X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=t%2Fdb_dependent%2FRecordProcessor_EmbedSeeFromHeadings.t;h=0b9d5f0dedf1f451a1daf8d4b98c0e45761bb085;hb=7ce858491b86b6fe4f85c0cb5e50f66288c474b0;hp=4742983085b11ec86f4d9397aa43bbd09a16b5e3;hpb=e5a24bbbdd0d0e9ff09bfaadfe4c4bb37312e7ec;p=srvgit diff --git a/t/db_dependent/RecordProcessor_EmbedSeeFromHeadings.t b/t/db_dependent/RecordProcessor_EmbedSeeFromHeadings.t index 4742983085..0b9d5f0ded 100755 --- a/t/db_dependent/RecordProcessor_EmbedSeeFromHeadings.t +++ b/t/db_dependent/RecordProcessor_EmbedSeeFromHeadings.t @@ -4,18 +4,18 @@ # # This file is part of Koha. # -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. # -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along -# with Koha; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . use strict; use warnings; @@ -25,6 +25,7 @@ use Koha::Authority; use Test::More; use Test::MockModule; +use Test::MockObject; BEGIN { use_ok('Koha::RecordProcessor'); @@ -63,4 +64,51 @@ my $result = $processor->process($bib); is_deeply($result, $resultbib, 'Inserted see-from heading to record'); + +subtest "EmbedSeeFromHeadings should skip holdings fields" => sub { + + plan tests => 1; + + my $biblio_record = MARC::Record->new; + $biblio_record->add_fields( + [ '245', '0', '4', a => 'The Ifrane cookbook' ], + [ '952', ' ', ' ', a => 'Cooking', 9 => '1234' ] + ); + + my $record_copy = MARC::Record->new; + $record_copy->add_fields( + [ '245', '0', '4', a => 'The Ifrane cookbook' ], + [ '952', ' ', ' ', a => 'Cooking', 9 => '1234' ] + ); + + + my $koha_authority = new Test::MockModule('Koha::Authority'); + $koha_authority->mock( 'get_from_authid', sub { + + my $auth_record = MARC::Record->new; + + $auth_record->add_fields( + [ '001', '1234' ], + [ '150', ' ', ' ', a => 'Cooking' ], + [ '450', ' ', ' ', a => 'Cookery' ], + ); + + my $authority_object = Test::MockObject->new(); + $authority_object->mock( 'authid', sub { return '1234'; }); + $authority_object->mock( 'authtype', sub { return 'TOPIC_TERM'; }); + $authority_object->mock( 'schema', sub { return 'marc21'; }); + $authority_object->mock( 'record', sub { return $auth_record; }); + + return $authority_object; + }); + + my $processor = Koha::RecordProcessor->new({ + filters => ( 'EmbedSeeFromHeadings' ) + }); + + my $result = $processor->process($biblio_record); + + is_deeply($result, $record_copy, 'Holdings fields not processed to introduce See-from heading'); +}; + done_testing();