Bugzilla – Attachment 151977 Details for
Bug 33493
Add a filter relationship for branchtransfers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33493: (follow-up) Rename relationship and add test
Bug-33493-follow-up-Rename-relationship-and-add-te.patch (text/plain), 3.60 KB, created by
Marcel de Rooy
on 2023-06-02 09:13:19 UTC
(
hide
)
Description:
Bug 33493: (follow-up) Rename relationship and add test
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-06-02 09:13:19 UTC
Size:
3.60 KB
patch
obsolete
>From 56bfbfc034131f2b2d7fa93093792f21b3a7f7a1 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 31 May 2023 12:02:41 +0000 >Subject: [PATCH] Bug 33493: (follow-up) Rename relationship and add test >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Item.pm | 4 +-- > Koha/Schema/Result/Item.pm | 2 +- > t/db_dependent/Koha/Item.t | 54 +++++++++++++++++++++++++++++++++++++- > 3 files changed, 56 insertions(+), 4 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index d38265903f..7f5362dc68 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -565,7 +565,7 @@ we still expect the item to end up at a final location eventually. > sub get_transfer { > my ($self) = @_; > >- my $transfer = $self->_result->branchtransfer; >+ my $transfer = $self->_result->current_branchtransfers; > > return Koha::Item::Transfers->_new_from_dbic($transfer)->next; > } >@@ -590,7 +590,7 @@ we still expect the item to end up at a final location eventually. > sub get_transfers { > my ($self) = @_; > >- my $transfer_rs = $self->_result->branchtransfer; >+ my $transfer_rs = $self->_result->current_branchtransfers; > > return Koha::Item::Transfers->_new_from_dbic($transfer_rs); > } >diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm >index 72112d27d3..50a9aac2cd 100644 >--- a/Koha/Schema/Result/Item.pm >+++ b/Koha/Schema/Result/Item.pm >@@ -973,7 +973,7 @@ __PACKAGE__->many_to_many( > ); > > __PACKAGE__->has_many( >- "branchtransfer", >+ "current_branchtransfers", > "Koha::Schema::Result::Branchtransfer", > { 'foreign.itemnumber' => 'self.itemnumber' }, > { >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 8b6abda059..c5fd5fec1a 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -20,7 +20,7 @@ > use Modern::Perl; > use utf8; > >-use Test::More tests => 28; >+use Test::More tests => 29; > use Test::Exception; > use Test::MockModule; > >@@ -2175,3 +2175,55 @@ subtest 'is_denied_renewal' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'current_branchtransfers relationship' => sub { >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $biblio = $builder->build_sample_biblio(); >+ my $item = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ } >+ ); >+ my $transfers = $item->_result->current_branchtransfers; >+ is( ref($transfers), 'DBIx::Class::ResultSet', >+ 'current_branchtransfers returns a Koha::Item::Transfers object set' ); >+ is( $transfers->count, 0, >+ "Empty Koha::Item::Transfers set returned if no return_claims" ); >+ my $transfer1 = $builder->build( >+ { >+ source => 'Branchtransfer', >+ value => { >+ itemnumber => $item->itemnumber, >+ datearrived => dt_from_string, >+ } >+ } >+ ); >+ my $transfer2 = $builder->build( >+ { >+ source => 'Branchtransfer', >+ value => { >+ itemnumber => $item->itemnumber, >+ datearrived => undef, >+ datecancelled => dt_from_string, >+ } >+ } >+ ); >+ my $transfer3 = $builder->build( >+ { >+ source => 'Branchtransfer', >+ value => { >+ itemnumber => $item->itemnumber, >+ datearrived => undef, >+ datecancelled => undef, >+ } >+ } >+ ); >+ >+ is( $item->_result->current_branchtransfers()->count, >+ 1, "One transfer found for item" ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.30.2
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 33493
:
149464
|
149469
|
151865
|
151923
|
151924
|
151976
| 151977 |
151978