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

(-)a/Koha/Subscription.pm (+12 lines)
Lines 23-28 use Carp; Link Here
23
23
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::Biblios;
25
use Koha::Biblios;
26
use Koha::Acquisition::Booksellers;
26
27
27
use base qw(Koha::Object);
28
use base qw(Koha::Object);
28
29
Lines 48-53 sub biblio { Link Here
48
    return scalar Koha::Biblios->find($self->biblionumber);
49
    return scalar Koha::Biblios->find($self->biblionumber);
49
}
50
}
50
51
52
=head3 vendor
53
54
Returns the vendor/supplier linked to this subscription as a Koha::Acquisition::Bookseller object
55
56
=cut
57
58
sub vendor {
59
    my ($self) = @_;
60
    return scalar Koha::Acquisition::Booksellers->find($self->aqbooksellerid);
61
}
62
51
=head3 type
63
=head3 type
52
64
53
=cut
65
=cut
(-)a/t/db_dependent/Koha/Subscription.t (-4 / +21 lines)
Lines 19-33 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 Koha::Subscription;
24
use Koha::Subscriptions;
25
use Koha::Biblio;
25
use Koha::Biblio;
26
26
27
use t::lib::TestBuilder;
28
27
my $schema = Koha::Database->new->schema;
29
my $schema = Koha::Database->new->schema;
28
$schema->storage->txn_begin;
30
$schema->storage->txn_begin;
29
31
30
subtest 'Koha::Subscription::biblio' => sub {
32
my $builder = t::lib::TestBuilder->new;
33
34
subtest 'Koha::Subscription->biblio' => sub {
31
    plan tests => 1;
35
    plan tests => 1;
32
36
33
    my $biblio = Koha::Biblio->new()->store();
37
    my $biblio = Koha::Biblio->new()->store();
Lines 39-44 subtest 'Koha::Subscription::biblio' => sub { Link Here
39
    is($b->biblionumber, $biblio->biblionumber, 'Koha::Subscription::biblio returns the correct biblio');
43
    is($b->biblionumber, $biblio->biblionumber, 'Koha::Subscription::biblio returns the correct biblio');
40
};
44
};
41
45
46
subtest 'Koha::Subscription->vendor' => sub {
47
    plan tests => 2;
48
    my $vendor = $builder->build( { source => 'Aqbookseller' } );
49
    my $subscription = $builder->build(
50
        {
51
            source => 'Subscription',
52
            value  => { aqbooksellerid => $vendor->{id} }
53
        }
54
    );
55
    my $object = Koha::Subscriptions->find( $subscription->{subscriptionid} );
56
    is( ref($object->vendor), 'Koha::Acquisition::Bookseller', 'Koha::Subscription->vendor should return a Koha::Acquisition::Bookseller' );
57
    is( $object->vendor->id, $subscription->{aqbooksellerid}, 'Koha::Subscription->vendor should return the correct vendor' );
58
};
59
42
$schema->storage->txn_rollback;
60
$schema->storage->txn_rollback;
43
61
44
1;
62
1;
45
- 

Return to bug 20599