View | Details | Raw Unified | Return to bug 22144
Collapse All | Expand All

(-)a/Koha/Biblio.pm (-3 / +20 lines)
Lines 28-39 use Koha::DateUtils qw( dt_from_string ); Link Here
28
28
29
use base qw(Koha::Object);
29
use base qw(Koha::Object);
30
30
31
use Koha::Items;
32
use Koha::Biblioitems;
33
use Koha::ArticleRequests;
34
use Koha::ArticleRequest::Status;
31
use Koha::ArticleRequest::Status;
32
use Koha::ArticleRequests;
33
use Koha::Biblio::Metadatas;
34
use Koha::Biblioitems;
35
use Koha::IssuingRules;
35
use Koha::IssuingRules;
36
use Koha::Item::Transfer::Limits;
36
use Koha::Item::Transfer::Limits;
37
use Koha::Items;
37
use Koha::Libraries;
38
use Koha::Libraries;
38
use Koha::Subscriptions;
39
use Koha::Subscriptions;
39
40
Lines 61-66 sub store { Link Here
61
    return $self->SUPER::store;
62
    return $self->SUPER::store;
62
}
63
}
63
64
65
=head3 metadata
66
67
my $metadata = $biblio->metadata();
68
69
Returns a Koha::Biblio::Metadata object
70
71
=cut
72
73
sub metadata {
74
    my ( $self ) = @_;
75
76
    $self->{_metadata} ||= Koha::Biblio::Metadatas->find( { biblionumber => $self->id } );
77
78
    return $self->{_metadata};
79
}
80
64
=head3 subtitles
81
=head3 subtitles
65
82
66
my @subtitles = $biblio->subtitles();
83
my @subtitles = $biblio->subtitles();
(-)a/Koha/Biblio/Metadata.pm (+24 lines)
Lines 19-24 use Modern::Perl; Link Here
19
19
20
use Carp;
20
use Carp;
21
21
22
use C4::Biblio qw();
23
22
use Koha::Database;
24
use Koha::Database;
23
25
24
use base qw(Koha::Object);
26
use base qw(Koha::Object);
Lines 33-38 Koha::Metadata - Koha Metadata Object class Link Here
33
35
34
=cut
36
=cut
35
37
38
=head3 record
39
40
my @record = $biblio->record($params);
41
42
Returns a MARC::Record object for a record.
43
44
This method accepts the same paramters as C4::Biblio::GetMarcBiblio,
45
but does not require the 'biblionumber' parameter.
46
47
=cut
48
49
sub record {
50
    my ( $self, $params ) = @_;
51
52
    $params->{biblionumber} = $self->biblionumber;
53
54
    my $record = C4::Biblio::GetMarcBiblio($params);
55
56
    return $record;
57
}
58
59
36
=head3 type
60
=head3 type
37
61
38
=cut
62
=cut
(-)a/t/db_dependent/Koha/Biblio.t (-1 / +57 lines)
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 Test::More tests => 3;
21
22
use C4::Biblio;
23
use Koha::Database;
24
25
BEGIN {
26
    use_ok('Koha::Biblio');
27
    use_ok('Koha::Biblios');
28
}
29
30
my $schema = Koha::Database->new->schema;
31
32
subtest 'metadata() tests' => sub {
33
34
    plan tests => 4;
35
36
    $schema->storage->txn_begin;
37
38
    my $title = 'Oranges and Peaches';
39
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, '');
44
45
    my $biblio = Koha::Biblios->find( $biblionumber );
46
    is( ref $biblio, 'Koha::Biblio', 'Found a Koha::Biblio object' );
47
48
    my $metadata = $biblio->metadata;
49
    is( ref $metadata, 'Koha::Biblio::Metadata', 'Method metadata() returned a Koha::Biblio::Metadata object' );
50
51
    my $record2 = $metadata->record;
52
    is( ref $record2, 'MARC::Record', 'Method record() returned a MARC::Record object' );
53
54
    is( $record2->field('245')->subfield("a"), $title, 'Title in 245$a matches title from original record object' );
55
56
    $schema->storage->txn_rollback;
57
};

Return to bug 22144