BUG8446, QA Followup: Minor Code Tidies
[koha.git] / t / db_dependent / RecordProcessor_EmbedSeeFromHeadings.t
blob4742983085b11ec86f4d9397aa43bbd09a16b5e3
1 #!/usr/bin/perl
3 # Copyright 2012 C & P Bibliography Services
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 use strict;
21 use warnings;
22 use File::Spec;
23 use MARC::Record;
24 use Koha::Authority;
26 use Test::More;
27 use Test::MockModule;
29 BEGIN {
30 use_ok('Koha::RecordProcessor');
33 my $module = new Test::MockModule('MARC::Record');
34 $module->mock('new_from_xml', sub {
35 my $record = MARC::Record->new;
37 $record->add_fields(
38 [ '001', '1234' ],
39 [ '150', ' ', ' ', a => 'Cooking' ],
40 [ '450', ' ', ' ', a => 'Cookery' ],
43 return $record;
44 });
46 my $bib = MARC::Record->new;
47 $bib->add_fields(
48 [ '245', '0', '4', a => 'The Ifrane cookbook' ],
49 [ '650', ' ', ' ', a => 'Cooking', 9 => '1234' ]
52 my $resultbib = MARC::Record->new;
53 $resultbib->add_fields(
54 [ '245', '0', '4', a => 'The Ifrane cookbook' ],
55 [ '650', ' ', ' ', a => 'Cooking', 9 => '1234' ],
56 [ '650', 'z', ' ', a => 'Cookery' ]
59 my $processor = Koha::RecordProcessor->new( { filters => ( 'EmbedSeeFromHeadings' ) } );
60 is(ref($processor), 'Koha::RecordProcessor', 'Created record processor');
62 my $result = $processor->process($bib);
64 is_deeply($result, $resultbib, 'Inserted see-from heading to record');
66 done_testing();