Bug 9978: Replace license header with the correct license (GPLv3+)
[koha-equinox.git] / t / db_dependent / RecordProcessor_EmbedSeeFromHeadings.t
1 #!/usr/bin/perl
2
3 # Copyright 2012 C & P Bibliography Services
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 strict;
21 use warnings;
22 use File::Spec;
23 use MARC::Record;
24 use Koha::Authority;
25
26 use Test::More;
27 use Test::MockModule;
28
29 BEGIN {
30         use_ok('Koha::RecordProcessor');
31 }
32
33 my $module = new Test::MockModule('MARC::Record');
34 $module->mock('new_from_xml', sub {
35     my $record = MARC::Record->new;
36
37     $record->add_fields(
38         [ '001', '1234' ],
39         [ '150', ' ', ' ', a => 'Cooking' ],
40         [ '450', ' ', ' ', a => 'Cookery' ],
41         );
42
43     return $record;
44 });
45
46 my $bib = MARC::Record->new;
47 $bib->add_fields(
48     [ '245', '0', '4', a => 'The Ifrane cookbook' ],
49     [ '650', ' ', ' ', a => 'Cooking', 9 => '1234' ]
50     );
51
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' ]
57     );
58
59 my $processor = Koha::RecordProcessor->new( { filters => ( 'EmbedSeeFromHeadings' ) } );
60 is(ref($processor), 'Koha::RecordProcessor', 'Created record processor');
61
62 my $result = $processor->process($bib);
63
64 is_deeply($result, $resultbib, 'Inserted see-from heading to record');
65
66 done_testing();