3 # Copyright 2014 Catalyst IT
5 # This file is part of Koha.
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>.
23 use C4
::Biblio
qw( AddBiblio );
28 use Test
::More tests
=> 4;
30 use_ok
('Koha::Biblio');
31 use_ok
('Koha::Biblios');
33 my $schema = Koha
::Database
->new()->schema();
34 $schema->storage->txn_begin();
36 my $dbh = C4
::Context
->dbh;
37 $dbh->{RaiseError
} = 1;
39 my @branches = Koha
::Libraries
->search();
40 my $borrower = Koha
::Patrons
->search()->next();
42 my $biblio = MARC
::Record
->new();
43 $biblio->append_fields(
44 MARC
::Field
->new( '100', ' ', ' ', a
=> 'Hall, Kyle' ),
45 MARC
::Field
->new( '245', ' ', ' ', a
=> "Test Record", b
=> "Test Record Subtitle", b
=> "Another Test Record Subtitle" ),
47 my ( $biblionumber, $biblioitemnumber ) = AddBiblio
( $biblio, '' );
49 my $field_mappings = Koha
::Database
->new()->schema()->resultset('Fieldmapping');
50 $field_mappings->delete();
51 $field_mappings->create( { field
=> 'subtitle', fieldcode
=> '245', subfieldcode
=> 'b' } );
53 $biblio = Koha
::Biblios
->find( $biblionumber );
54 my @subtitles = $biblio->subtitles();
55 is
( $subtitles[0], 'Test Record Subtitle', 'Got first subtitle correctly' );
56 is
( $subtitles[1], 'Another Test Record Subtitle', 'Got second subtitle correctly' );
58 $schema->storage->txn_rollback();