@@ -, +, @@ Koha::Acq::Bookseller methods - Create a vendor, basket and contact - Edit the vendor => the contact must appears - Go to the view of a vendor => you cannot delete the vendor, it has - Create another vendor, without basket - Go to the view of the vendor => You can delete it % prove t/db_dependent/Koha/Acquisition/Booksellers.t --- Koha/Acquisition/Bookseller.pm | 7 +++++-- t/db_dependent/Koha/Acquisition/Booksellers.t | 13 ++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) --- a/Koha/Acquisition/Bookseller.pm +++ a/Koha/Acquisition/Bookseller.pm @@ -41,7 +41,8 @@ Returns the list of baskets for the vendor sub baskets { my ( $self ) = @_; - return $self->{_result}->aqbaskets; + my $baskets_rs = $self->_result->aqbaskets; + return Koha::Acquisition::Baskets->_new_from_dbic( $baskets_rs ); } =head3 contacts @@ -55,7 +56,8 @@ Returns the list of contacts for the vendor sub contacts { my ($self) = @_; - return Koha::Acquisition::Bookseller::Contacts->search( { booksellerid => $self->id } ); + my $contacts_rs = $self->_result->aqcontacts; + return Koha::Acquisition::Bookseller::Contacts->_new_from_dbic( $contacts_rs ); } =head3 subscriptions @@ -70,6 +72,7 @@ Returns the list of subscriptions for the vendor sub subscriptions { my ($self) = @_; + # FIXME FK missing at DB level return Koha::Subscriptions->search( { aqbooksellerid => $self->id } ); } --- a/t/db_dependent/Koha/Acquisition/Booksellers.t +++ a/t/db_dependent/Koha/Acquisition/Booksellers.t @@ -43,7 +43,7 @@ subtest '->baskets() tests' => sub { my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } ); - is( $vendor->baskets, 0, 'Vendor has no baskets' ); + is( $vendor->baskets->count, 0, 'Vendor has no baskets' ); # Add two baskets my $basket_1_id = C4::Acquisition::NewBasket( $vendor->id, $patron->borrowernumber, 'basketname1' ); @@ -51,7 +51,7 @@ subtest '->baskets() tests' => sub { # Re-fetch vendor $vendor = Koha::Acquisition::Booksellers->find( $vendor->id ); - is( $vendor->baskets, 2, 'Vendor has two baskets' ); + is( $vendor->baskets->count, 2, 'Vendor has two baskets' ); $schema->storage->txn_rollback(); }; @@ -139,7 +139,7 @@ subtest '->subscriptions() tests' => sub { subtest '->contacts() tests' => sub { - plan tests => 4; + plan tests => 3; $schema->storage->txn_begin(); @@ -161,10 +161,9 @@ subtest '->contacts() tests' => sub { # Re-fetch vendor $vendor = Koha::Acquisition::Booksellers->find( $vendor->id ); - is( $vendor->contacts->count, 2, 'Vendor has two contacts' ); - foreach my $contact ( $vendor->contacts ) { - is( ref($contact), 'Koha::Acquisition::Bookseller::Contact', 'Type is correct' ); - } + my $contacts = $vendor->contacts; + is( $contacts->count, 2, 'Vendor has two contacts' ); + is( ref($contacts), 'Koha::Acquisition::Bookseller::Contacts', 'Type is correct' ); $schema->storage->txn_rollback(); }; --