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 => 3;
26 use_ok('Koha::Biblio');
27 use_ok('Koha::Biblios');
30 my $schema = Koha::Database->new->schema;
32 subtest 'metadata() tests' => sub {
36 $schema->storage->txn_begin;
38 my $title = 'Oranges and Peaches';
40 my $record = MARC::Record->new();
41 my $field = MARC::Field->new('245','','','a' => $title);
42 $record->append_fields( $field );
43 my ($biblionumber) = C4::Biblio::AddBiblio($record, '');
45 my $biblio = Koha::Biblios->find( $biblionumber );
46 is( ref $biblio, 'Koha::Biblio', 'Found a Koha::Biblio object' );
48 my $metadata = $biblio->metadata;
49 is( ref $metadata, 'Koha::Biblio::Metadata', 'Method metadata() returned a Koha::Biblio::Metadata object' );
51 my $record2 = $metadata->record;
52 is( ref $record2, 'MARC::Record', 'Method record() returned a MARC::Record object' );
54 is( $record2->field('245')->subfield("a"), $title, 'Title in 245$a matches title from original record object' );
56 $schema->storage->txn_rollback;