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>.
20 use Test
::More tests
=> 2;
22 BEGIN { use_ok
('Koha::Util::MARC'); }
24 subtest
'set_marc_field' => sub {
27 my $record = MARC
::Record
->new();
29 Koha
::Util
::MARC
::set_marc_field
($record, '999$9', 'foobar');
30 my @fields = $record->field('999');
31 is
(scalar @fields, 1, 'Created one field');
32 my @subfields = $fields[0]->subfield('9');
33 is
(scalar @subfields, 1, 'Created one subfield');
34 is
($subfields[0], 'foobar', 'Created subfield has correct value');
36 Koha
::Util
::MARC
::set_marc_field
($record, '999$9', 'foobaz');
37 @fields = $record->field('999');
38 is
(scalar @fields, 1, 'No additional field created');
39 @subfields = $fields[0]->subfield('9');
40 is
(scalar @subfields, 1, 'No additional subfield created');
41 is
($subfields[0], 'foobaz', 'Subfield value has been changed');