Bugzilla – Attachment 76295 Details for
Bug 18072
Add Koha objects for Branch Transfer Limits
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18072: (QA-follow-up) let Koha::Item->can_be_transferred take HASHref as param
Bug-18072-QA-follow-up-let-KohaItem-canbetransferr.patch (text/plain), 3.81 KB, created by
Kyle M Hall (khall)
on 2018-06-22 14:44:41 UTC
(
hide
)
Description:
Bug 18072: (QA-follow-up) let Koha::Item->can_be_transferred take HASHref as param
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-06-22 14:44:41 UTC
Size:
3.81 KB
patch
obsolete
>From 4d55c85178aab4620741749ee7644db161ca1015 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Fri, 10 Feb 2017 15:08:47 +0200 >Subject: [PATCH] Bug 18072: (QA-follow-up) let Koha::Item->can_be_transferred > take HASHref as param > >This patch changes Koha::Item->can_be_transferred to accept a HASHref as follows: >$item->can_be_transferred({ to => $library, from => $library2 }) > >To test: >1. prove t/db_dependent/Koha/Items.t > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Item.pm | 8 +++++++- > t/db_dependent/Koha/Items.t | 12 ++++++------ > 2 files changed, 13 insertions(+), 7 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 6d81cc5566..890ebbd127 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -194,6 +194,7 @@ sub can_article_request { > > =head3 can_be_transferred > >+$item->can_be_transferred({ to => $to_library, from => $from_library }) > Checks if an item can be transferred to given library. > > This feature is controlled by two system preferences: >@@ -201,17 +202,22 @@ UseBranchTransferLimits to enable / disable the feature > BranchTransferLimitsType to use either an itemnumber or ccode as an identifier > for setting the limitations > >+Takes HASHref that can have the following parameters: > MANDATORY PARAMETERS: > $to : Koha::Library or branchcode string > OPTIONAL PARAMETERS: > $from : Koha::Library or branchcode string # if not given, item holdingbranch > # will be used instead > >+Returns 1 if item can be transferred to $to_library, otherwise 0. >+ > =cut > > sub can_be_transferred { >- my ($self, $to, $from) = @_; >+ my ($self, $params) = @_; > >+ my $to = $params->{'to'}; >+ my $from = $params->{'from'}; > if (ref($to) ne 'Koha::Library') { > my $tobranchcode = defined $to ? $to : ''; > $to = Koha::Libraries->find($tobranchcode); >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index e40396b9e1..02272d219a 100644 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -142,7 +142,7 @@ subtest 'can_be_transferred' => sub { > fromBranch => $library1, > toBranch => $library2, > })->count, 0, 'There are no transfer limits between libraries.'); >- ok($item->can_be_transferred($library2), >+ ok($item->can_be_transferred({ to => $library2 }), > 'Item can be transferred between libraries.'); > > my $limit = Koha::Item::Transfer::Limit->new({ >@@ -154,15 +154,15 @@ subtest 'can_be_transferred' => sub { > fromBranch => $library1, > toBranch => $library2, > })->count, 1, 'Given we have added a transfer limit,'); >- is($item->can_be_transferred($library2), 0, >+ is($item->can_be_transferred({ to => $library2 }), 0, > 'Item can no longer be transferred between libraries.'); >- is($item->can_be_transferred($library2, $library1), 0, >+ is($item->can_be_transferred({ to => $library2, $library1 }), 0, > 'We get the same result also if we pass the from-library parameter.'); >- eval { $item->can_be_transferred(); }; >+ eval { $item->can_be_transferred({ to => undef }); }; > is(ref($@), 'Koha::Exceptions::Library::NotFound', 'Exception thrown when no library given.'); >- eval { $item->can_be_transferred('heaven'); }; >+ eval { $item->can_be_transferred({ to => 'heaven' }); }; > is(ref($@), 'Koha::Exceptions::Library::NotFound', 'Exception thrown when invalid library is given.'); >- eval { $item->can_be_transferred($library2, 'hell'); }; >+ eval { $item->can_be_transferred({ to => $library2, from => 'hell' }); }; > is(ref($@), 'Koha::Exceptions::Library::NotFound', 'Exception thrown when invalid library is given.'); > }; > >-- >2.15.2 (Apple Git-101.1)
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 18072
:
59979
|
59980
|
59981
|
59982
|
60009
|
60010
|
60011
|
60116
|
60117
|
60782
|
60783
|
60784
|
63683
|
63684
|
63685
|
63686
|
63687
|
66724
|
67049
|
67050
|
67051
|
67052
|
67053
|
67054
|
67209
|
76282
|
76283
|
76284
|
76285
|
76286
|
76287
|
76288
|
76292
|
76293
|
76294
| 76295 |
76296
|
76297
|
76298