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

(-)a/Koha/Biblio.pm (+17 lines)
Lines 280-285 sub biblioitem { Link Here
280
    return $self->{_biblioitem};
280
    return $self->{_biblioitem};
281
}
281
}
282
282
283
=head3 subscriptions
284
285
my $subscriptions = $self->subscriptions
286
287
Returns the related Koha::Subscriptions object for this Biblio object
288
289
=cut
290
291
sub subscriptions {
292
    my ($self) = @_;
293
294
    $self->{_subscriptions} ||= Koha::Subscriptions->search( { biblionumber => $self->biblionumber } );
295
296
    return $self->{_subscriptions};
297
}
298
299
283
=head3 type
300
=head3 type
284
301
285
=cut
302
=cut
(-)a/t/db_dependent/Koha/Biblios.t (-2 / +18 lines)
Lines 19-30 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 1;
22
use Test::More tests => 2;
23
23
24
use C4::Reserves;
24
use C4::Reserves;
25
25
26
use Koha::Biblios;
26
use Koha::Biblios;
27
use Koha::Patrons;
27
use Koha::Patrons;
28
use Koha::Subscriptions;
28
use t::lib::TestBuilder;
29
use t::lib::TestBuilder;
29
use t::lib::Mocks;
30
use t::lib::Mocks;
30
31
Lines 52-57 subtest 'holds' => sub { Link Here
52
    is( $holds->next->borrowernumber, $patron->borrowernumber, '->holds should return the correct hold' );
53
    is( $holds->next->borrowernumber, $patron->borrowernumber, '->holds should return the correct hold' );
53
};
54
};
54
55
56
subtest 'subscriptions' => sub {
57
    plan tests => 2;
58
    $builder->build(
59
        { source => 'Subscription', value => { biblionumber => $biblio->id } }
60
    );
61
    $builder->build(
62
        { source => 'Subscription', value => { biblionumber => $biblio->id } }
63
    );
64
    my $biblio        = Koha::Biblios->find( $biblio->id );
65
    my $subscriptions = $biblio->subscriptions;
66
    is( ref($subscriptions), 'Koha::Subscriptions',
67
        'Koha::Biblio->subscriptions should return a Koha::Subscriptions object'
68
    );
69
    is( $subscriptions->count, 2, 'Koha::Biblio->subscriptions should return the correct number of subscriptions');
70
};
71
55
$schema->storage->txn_rollback;
72
$schema->storage->txn_rollback;
56
73
57
1;
74
1;
58
- 

Return to bug 18258