Bugzilla – Attachment 86368 Details for
Bug 17509
Notify patrons to return items requested on hold by another person
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17509: Added tests
Bug-17509-Added-tests.patch (text/plain), 5.80 KB, created by
Josef Moravec
on 2019-03-08 10:12:48 UTC
(
hide
)
Description:
Bug 17509: Added tests
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2019-03-08 10:12:48 UTC
Size:
5.80 KB
patch
obsolete
>From f26f761b2e100ddf0a80c51ea0d2a12681a8c8e5 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Radek=20=C5=A0iman?= <rbit@rbit.cz> >Date: Fri, 5 May 2017 21:04:16 +0200 >Subject: [PATCH] Bug 17509: Added tests > >prove t/db_dependent/Reserves/Notification.t > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >Test pass >--- > C4/Reserves.pm | 1 + > t/db_dependent/Reserves/Notification.t | 167 +++++++++++++++++++++++++++++++++ > 2 files changed, 168 insertions(+) > create mode 100755 t/db_dependent/Reserves/Notification.t > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 1065321212..e70b80cbd9 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -140,6 +140,7 @@ BEGIN { > IsItemOnHoldAndFound > > GetMaxPatronHoldsForRecord >+ GetBorrowersToSatisfyHold > ); > @EXPORT_OK = qw( MergeHolds ); > } >diff --git a/t/db_dependent/Reserves/Notification.t b/t/db_dependent/Reserves/Notification.t >new file mode 100755 >index 0000000000..35ac5dc5d7 >--- /dev/null >+++ b/t/db_dependent/Reserves/Notification.t >@@ -0,0 +1,167 @@ >+#!/usr/bin/perl >+ >+# Copyright 2017 R-Bit Technology, s.r.o. >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 5; >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+use C4::Reserves qw( GetBorrowersToSatisfyHold ); >+use Koha::Database; >+use Koha::Holds; >+use Data::Dumper; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new(); >+my $libraryA = $builder->build( >+ { >+ source => 'Branch', >+ } >+); >+ >+my $libraryB = $builder->build( >+ { >+ source => 'Branch', >+ } >+); >+ >+my $holdRequestorInA = $builder->build( >+ { >+ source => 'Borrower', >+ value => { >+ branchcode => $libraryA->{branchcode}, >+ cardnumber => '001', >+ }, >+ } >+); >+ >+my $patronInA = $builder->build( >+ { >+ source => 'Borrower', >+ value => { >+ branchcode => $libraryA->{branchcode}, >+ cardnumber => '002', >+ }, >+ } >+); >+ >+my $patronInB = $builder->build( >+ { >+ source => 'Borrower', >+ value => { >+ branchcode => $libraryB->{branchcode}, >+ cardnumber => '003', >+ }, >+ } >+); >+ >+my $biblio = $builder->build( >+ { >+ source => 'Biblio', >+ value => { >+ title => 'Title 1', >+ }, >+ } >+); >+my $itemType = $builder->build( >+ { >+ source => 'Itemtype', >+ } >+); >+my $itemInA = $builder->build( >+ { >+ source => 'Item', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ homebranch => $libraryA->{branchcode}, >+ holdingbranch => $libraryA->{branchcode}, >+ itype => $itemType->{itemtype}, >+ }, >+ } >+); >+my $itemInB = $builder->build( >+ { >+ source => 'Item', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ homebranch => $libraryB->{branchcode}, >+ holdingbranch => $libraryB->{branchcode}, >+ itype => $itemType->{itemtype}, >+ }, >+ } >+); >+ >+my $issueOfItemInA = $builder->build( >+ { >+ source => 'Issue', >+ value => { >+ borrowernumber => $patronInB->{borrowernumber}, >+ itemnumber => $itemInA->{itemnumber}, >+ }, >+ } >+); >+my $issueOfItemInB = $builder->build( >+ { >+ source => 'Issue', >+ value => { >+ borrowernumber => $patronInA->{borrowernumber}, >+ itemnumber => $itemInB->{itemnumber}, >+ }, >+ } >+); >+ >+t::lib::Mocks::mock_preference('NotifyToReturnItemWhenHoldIsPlaced', 1); # Assuming the notification is allowed >+ >+my $hold = Koha::Hold->new( >+ { >+ borrowernumber => $holdRequestorInA->{borrowernumber}, >+ biblionumber => $biblio->{biblionumber}, >+ reservedate => '2017-01-01', >+ branchcode => $holdRequestorInA->{branchcode}, >+ priority => 1, >+ reservenotes => 'dummy text', >+ #itemnumber => $itemInA->{itemnumber}, >+ waitingdate => '2099-01-01', >+ expirationdate => '2099-01-01', >+ itemtype => $itemInA->{itype}, >+ } >+)->store(); >+ >+my @borrowers; >+ >+t::lib::Mocks::mock_preference('NotifyToReturnItemFromLibrary', 'AnyLibrary'); # Assuming items from any library >+@borrowers = GetBorrowersToSatisfyHold($hold); >+is(scalar(grep {defined $_} @borrowers), 2, "2 borrowers with requested item found in any library"); >+ >+t::lib::Mocks::mock_preference('NotifyToReturnItemFromLibrary', 'RequestorLibrary'); # Assuming items from requestor library >+@borrowers = GetBorrowersToSatisfyHold($hold); >+is(scalar(grep {defined $_} @borrowers), 1, "1 item found in requestor library"); >+is($borrowers[0]->{cardnumber}, "002", " ...and it is in 002's hands"); >+ >+t::lib::Mocks::mock_preference('NotifyToReturnItemFromLibrary', 'ItemHomeLibrary'); # Assuming items from the same library as requested item >+@borrowers = GetBorrowersToSatisfyHold($hold); >+is(scalar(grep {defined $_} @borrowers), 1, "1 item found in the same library as the requested item"); >+is($borrowers[0]->{cardnumber}, "003", " ...and it is in 003's hands"); >+ >+$schema->storage->txn_rollback; >+ >+1; >-- >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 17509
:
57143
|
57144
|
57145
|
57146
|
57147
|
57148
|
57149
|
57150
|
57157
|
57159
|
57160
|
57161
|
57162
|
57163
|
57164
|
57165
|
63258
|
63269
|
63270
|
63271
|
63272
|
63273
|
63274
|
63275
|
63276
|
63277
|
67982
|
80452
|
80453
|
80454
|
80455
|
80456
|
80457
|
80458
|
80459
|
80460
|
80461
|
86365
|
86366
|
86367
| 86368 |
86369