Bugzilla – Attachment 98157 Details for
Bug 22685
Koha::Acquisition::Bookseller methods should return Koha::Objects using the DBIx::Class relationships
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22685: Use DBIx::Class relationships in Koha::Acq::Bookseller methods
Bug-22685-Use-DBIxClass-relationships-in-KohaAcqBo.patch (text/plain), 3.66 KB, created by
Jonathan Druart
on 2020-01-30 11:39:08 UTC
(
hide
)
Description:
Bug 22685: Use DBIx::Class relationships in Koha::Acq::Bookseller methods
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-01-30 11:39:08 UTC
Size:
3.66 KB
patch
obsolete
>From 9a7e6a874503d30f62fc2d94e69e52f086dd8990 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 30 Jan 2020 12:26:57 +0100 >Subject: [PATCH] Bug 22685: Use DBIx::Class relationships in > Koha::Acq::Bookseller methods > >To match PERL15 we change the behavior of Koha::Object methods to make >them use the DBIx::Class relationships. > >Test plan: >- 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 >a basket attached >- Create another vendor, without basket >- Go to the view of the vendor => You can delete it > >Additionally: > % prove t/db_dependent/Koha/Acquisition/Booksellers.t >must return green >--- > Koha/Acquisition/Bookseller.pm | 7 +++++-- > t/db_dependent/Koha/Acquisition/Booksellers.t | 13 ++++++------- > 2 files changed, 11 insertions(+), 9 deletions(-) > >diff --git a/Koha/Acquisition/Bookseller.pm b/Koha/Acquisition/Bookseller.pm >index 708ae51461..3456cdc545 100644 >--- a/Koha/Acquisition/Bookseller.pm >+++ b/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 } ); > } > >diff --git a/t/db_dependent/Koha/Acquisition/Booksellers.t b/t/db_dependent/Koha/Acquisition/Booksellers.t >index e3870cd9f8..5b5f58c100 100644 >--- a/t/db_dependent/Koha/Acquisition/Booksellers.t >+++ b/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(); > }; >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22685
:
98157
|
98510
|
101868