Bugzilla – Attachment 60783 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.62 KB, created by
Lari Taskula
on 2017-03-01 14:51:14 UTC
(
hide
)
Description:
Bug 18072: (QA-follow-up) let Koha::Item->can_be_transferred take HASHref as param
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2017-03-01 14:51:14 UTC
Size:
3.62 KB
patch
obsolete
>From 092df74120ee1e8cd30a03bc1174b34b05af94aa 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 >--- > 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 afa0778..9b458a7 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -163,6 +163,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: >@@ -170,17 +171,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 ed0f62d..715d864 100644 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -106,7 +106,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({ >@@ -118,15 +118,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.'); > }; > >-- >1.9.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