Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# This file is part of Koha. |
4 |
# |
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. |
9 |
# |
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. |
14 |
# |
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>. |
17 |
|
18 |
use Modern::Perl; |
19 |
|
20 |
use C4::Context; |
21 |
use C4::Biblio qw( AddBiblio ); |
22 |
use Koha::Database; |
23 |
use Koha::Branches; |
24 |
use Koha::Borrowers; |
25 |
|
26 |
use Test::More tests => 4; |
27 |
|
28 |
use_ok('Koha::Biblio'); |
29 |
use_ok('Koha::Biblios'); |
30 |
|
31 |
my $schema = Koha::Database->new()->schema(); |
32 |
$schema->storage->txn_begin(); |
33 |
|
34 |
my $dbh = C4::Context->dbh; |
35 |
$dbh->{RaiseError} = 1; |
36 |
|
37 |
my @branches = Koha::Branches->search(); |
38 |
my $borrower = Koha::Borrowers->search()->next(); |
39 |
|
40 |
my $biblio = MARC::Record->new(); |
41 |
$biblio->append_fields( |
42 |
MARC::Field->new( '100', ' ', ' ', a => 'Hall, Kyle' ), |
43 |
MARC::Field->new( '245', ' ', ' ', a => "Test Record", b => "Test Record Subtitle", b => "Another Test Record Subtitle" ), |
44 |
); |
45 |
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); |
46 |
|
47 |
my $field_mappings = Koha::Database->new()->schema()->resultset('Fieldmapping'); |
48 |
$field_mappings->delete(); |
49 |
$field_mappings->create( { field => 'subtitle', fieldcode => '245', subfieldcode => 'b' } ); |
50 |
|
51 |
$biblio = Koha::Biblios->find( $biblionumber ); |
52 |
my @subtitles = $biblio->subtitles(); |
53 |
is( $subtitles[0], 'Test Record Subtitle', 'Got first subtitle correctly' ); |
54 |
is( $subtitles[1], 'Another Test Record Subtitle', 'Got second subtitle correctly' ); |
55 |
|
56 |
$schema->storage->txn_rollback(); |
57 |
|
58 |
1; |