3 # This file is part of Koha.
5 # Copyright 2015 Mark Tompsett
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.
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.
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>.
29 use_ok('Koha::RecordProcessor');
32 our $VERSION = '3.23'; # Master version that I hope it gets in.
34 my $dbh = C4::Context->dbh;
36 my $database = Koha::Database->new();
37 my $schema = $database->schema();
38 $schema->storage->txn_begin();
40 $dbh->{RaiseError} = 1;
42 $dbh->do(q{UPDATE marc_subfield_structure SET hidden=2 WHERE tagfield='020';});
44 my $isbn = '0590353403';
45 my $title = 'Foundation';
46 my $marc_record = MARC::Record->new;
47 my $field = MARC::Field->new( '020', q{}, q{}, 'a' => $isbn );
48 $marc_record->append_fields($field);
49 $field = MARC::Field->new( '245', q{}, q{}, 'a' => $title );
50 $marc_record->append_fields($field);
52 my $processor = Koha::RecordProcessor->new(
53 { filters => ('ViewPolicy'), options => { 'test' => 'value1' } } );
55 ref( $processor->filters->[0] ),
56 'Koha::Filter::MARC::ViewPolicy',
57 'Created record processor with implicitly scoped ViewPolicy filter'
59 my $after_record = $processor->process($marc_record);
60 my $modified_record = $marc_record->clone;
61 my @isbn = $modified_record->field('020');
62 $modified_record->delete_fields(@isbn);
63 is_deeply( $modified_record, $after_record,
64 'Filtered and modified MARC record match' );
66 $schema->storage->txn_rollback();