3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21 use Test::More tests => 1;
23 use t::lib::TestBuilder;
26 use Koha::RecordProcessor;
28 my $schema = Koha::Database->schema();
29 my $builder = t::lib::TestBuilder->new();
31 subtest 'Index880InZebra tests' => sub {
35 $schema->storage->txn_begin();
38 my $biblio = $builder->build_sample_biblio({ title => 'Pastoral epistles' });
39 my $record = $biblio->metadata->record;
41 # Add an 880 alternate
42 $record->append_fields(
43 MARC::Field->new( '880', '', '', 6 => '245-01', a => '教牧書信' ),
46 my @fields_245 = $record->field('245');
47 is( @fields_245, 1, 'One title (245) field present before filtering');
48 is( $fields_245[0]->subfield('a'), 'Pastoral epistles', 'First 245 contains english title before filtering');
50 my @fields_880 = $record->field('880');
51 is( @fields_880, 1, 'One alternate graphic represnetation (880) field present before filtering');
52 is( $fields_880[0]->subfield('a'), '教牧書信', 'Alternate graphic represnations contains chinese characters prior to filtering' );
54 my $processor = Koha::RecordProcessor->new(
57 filters => ['Index880InZebra'],
60 is( ref($processor), 'Koha::RecordProcessor', 'Created record processor with Index880InZebra filter' );
62 my $result = $processor->process( $record );
63 is( ref($result), 'MARC::Record', 'It returns a reference to a MARC::Record object' );
65 @fields_245 = $result->field('245');
66 is( @fields_245, 2, 'Two title (245) fields present after filtering');
67 is( $fields_245[0]->subfield('a'), 'Pastoral epistles', 'First 245 contains english title after filtering');
68 is( $fields_245[1]->subfield('a'), '教牧書信', 'Second 245 contains chinese title from 880 after filtering' );
70 @fields_880 = $result->field('880');
71 is( @fields_880, 0, 'No alternate graphic represnetation (880) fields present after filtering');
73 $schema->storage->txn_rollback();