Bug 18292: Remove return 1 statements in tests
[koha.git] / t / db_dependent / Koha / BiblioUtils.t
1 #!/usr/bin/perl
2 #
3 # Copyright 2014 Catalyst IT
4 #
5 # This file is part of Koha.
6 #
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.
11 #
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.
16 #
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>.
19
20 use Modern::Perl;
21
22 use C4::Context;
23 use C4::Biblio qw( AddBiblio );
24 use Koha::Database;
25 use Koha::Libraries;
26 use Koha::Patrons;
27
28 use Test::More tests => 4;
29
30 use_ok('Koha::Biblio');
31 use_ok('Koha::Biblios');
32
33 my $schema = Koha::Database->new()->schema();
34 $schema->storage->txn_begin();
35
36 my $dbh = C4::Context->dbh;
37 $dbh->{RaiseError} = 1;
38
39 my @branches = Koha::Libraries->search();
40 my $borrower = Koha::Patrons->search()->next();
41
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" ),
46 );
47 my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' );
48
49 my $field_mappings = Koha::Database->new()->schema()->resultset('Fieldmapping');
50 $field_mappings->delete();
51 $field_mappings->create( { field => 'subtitle', fieldcode => '245', subfieldcode => 'b' } );
52
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' );
57
58 $schema->storage->txn_rollback();
59