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

(-)a/Koha/Acquisition/Bookseller.pm (-2 / +5 lines)
Lines 41-47 Returns the list of baskets for the vendor Link Here
41
41
42
sub baskets {
42
sub baskets {
43
    my ( $self ) = @_;
43
    my ( $self ) = @_;
44
    return $self->{_result}->aqbaskets;
44
    my $baskets_rs = $self->_result->aqbaskets;
45
    return Koha::Acquisition::Baskets->_new_from_dbic( $baskets_rs );
45
}
46
}
46
47
47
=head3 contacts
48
=head3 contacts
Lines 55-61 Returns the list of contacts for the vendor Link Here
55
56
56
sub contacts {
57
sub contacts {
57
    my ($self) = @_;
58
    my ($self) = @_;
58
    return Koha::Acquisition::Bookseller::Contacts->search( { booksellerid => $self->id } );
59
    my $contacts_rs = $self->_result->aqcontacts;
60
    return Koha::Acquisition::Bookseller::Contacts->_new_from_dbic( $contacts_rs );
59
}
61
}
60
62
61
=head3 subscriptions
63
=head3 subscriptions
Lines 70-75 Returns the list of subscriptions for the vendor Link Here
70
sub subscriptions {
72
sub subscriptions {
71
    my ($self) = @_;
73
    my ($self) = @_;
72
74
75
    # FIXME FK missing at DB level
73
    return Koha::Subscriptions->search( { aqbooksellerid => $self->id } );
76
    return Koha::Subscriptions->search( { aqbooksellerid => $self->id } );
74
}
77
}
75
78
(-)a/t/db_dependent/Koha/Acquisition/Booksellers.t (-8 / +6 lines)
Lines 43-49 subtest '->baskets() tests' => sub { Link Here
43
43
44
    my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } );
44
    my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } );
45
45
46
    is( $vendor->baskets, 0, 'Vendor has no baskets' );
46
    is( $vendor->baskets->count, 0, 'Vendor has no baskets' );
47
47
48
    # Add two baskets
48
    # Add two baskets
49
    my $basket_1_id = C4::Acquisition::NewBasket( $vendor->id, $patron->borrowernumber, 'basketname1' );
49
    my $basket_1_id = C4::Acquisition::NewBasket( $vendor->id, $patron->borrowernumber, 'basketname1' );
Lines 51-57 subtest '->baskets() tests' => sub { Link Here
51
51
52
    # Re-fetch vendor
52
    # Re-fetch vendor
53
    $vendor = Koha::Acquisition::Booksellers->find( $vendor->id );
53
    $vendor = Koha::Acquisition::Booksellers->find( $vendor->id );
54
    is( $vendor->baskets, 2, 'Vendor has two baskets' );
54
    is( $vendor->baskets->count, 2, 'Vendor has two baskets' );
55
55
56
    $schema->storage->txn_rollback();
56
    $schema->storage->txn_rollback();
57
};
57
};
Lines 139-145 subtest '->subscriptions() tests' => sub { Link Here
139
139
140
subtest '->contacts() tests' => sub {
140
subtest '->contacts() tests' => sub {
141
141
142
    plan tests => 4;
142
    plan tests => 3;
143
143
144
    $schema->storage->txn_begin();
144
    $schema->storage->txn_begin();
145
145
Lines 161-170 subtest '->contacts() tests' => sub { Link Here
161
161
162
    # Re-fetch vendor
162
    # Re-fetch vendor
163
    $vendor = Koha::Acquisition::Booksellers->find( $vendor->id );
163
    $vendor = Koha::Acquisition::Booksellers->find( $vendor->id );
164
    is( $vendor->contacts->count, 2, 'Vendor has two contacts' );
164
    my $contacts = $vendor->contacts;
165
    foreach my $contact ( $vendor->contacts ) {
165
    is( $contacts->count, 2, 'Vendor has two contacts' );
166
        is( ref($contact), 'Koha::Acquisition::Bookseller::Contact', 'Type is correct' );
166
    is( ref($contacts), 'Koha::Acquisition::Bookseller::Contacts', 'Type is correct' );
167
    }
168
167
169
    $schema->storage->txn_rollback();
168
    $schema->storage->txn_rollback();
170
};
169
};
171
- 

Return to bug 22685