Bugzilla – Attachment 52312 Details for
Bug 14364
Allow automatically canceled expired waiting holds to fill the next hold
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14364 [QA Followup] - Add unit tests
Bug-14364-QA-Followup---Add-unit-tests.patch (text/plain), 4.76 KB, created by
Kyle M Hall (khall)
on 2016-06-13 12:41:40 UTC
(
hide
)
Description:
Bug 14364 [QA Followup] - Add unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-06-13 12:41:40 UTC
Size:
4.76 KB
patch
obsolete
>From 5835b2889236e6ab0f6009fdeda07de699feb367 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 13 Jun 2016 12:41:09 +0000 >Subject: [PATCH] Bug 14364 [QA Followup] - Add unit tests > >--- > t/db_dependent/Holds/ExpireReservesAutoFill.t | 134 ++++++++++++++++++++++++++ > 1 file changed, 134 insertions(+) > create mode 100755 t/db_dependent/Holds/ExpireReservesAutoFill.t > >diff --git a/t/db_dependent/Holds/ExpireReservesAutoFill.t b/t/db_dependent/Holds/ExpireReservesAutoFill.t >new file mode 100755 >index 0000000..bbf0ae3 >--- /dev/null >+++ b/t/db_dependent/Holds/ExpireReservesAutoFill.t >@@ -0,0 +1,134 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+ >+use Test::More tests => 8; >+ >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ >+use MARC::Record; >+ >+use C4::Context; >+use C4::Biblio; >+use C4::Items; >+use Koha::Database; >+use Koha::Holds; >+ >+BEGIN { >+ use FindBin; >+ use lib $FindBin::Bin; >+ use_ok('C4::Reserves'); >+} >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new(); >+my $dbh = C4::Context->dbh; >+ >+# Create two random branches >+my $library = $builder->build( { source => 'Branch' } ); >+my $branchcode = $library->{branchcode}; >+ >+$dbh->do('DELETE FROM reserves'); >+$dbh->do('DELETE FROM message_queue'); >+ >+# Create a biblio instance for testing >+my ($biblionumber) = create_helper_biblio('DUMMY'); >+ >+# Create item instance for testing. >+my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = >+ AddItem( { homebranch => $branchcode, holdingbranch => $branchcode }, >+ $biblionumber ); >+ >+my $patron_1 = $builder->build( { source => 'Borrower' } ); >+my $patron_2 = $builder->build( { source => 'Borrower' } ); >+my $patron_3 = $builder->build( { source => 'Borrower' } ); >+ >+# Add a hold on the item for each of our patrons >+my $hold_1 = Koha::Hold->new( >+ { >+ priority => 0, >+ borrowernumber => $patron_1->{borrowernumber}, >+ branchcode => $library->{branchcode}, >+ biblionumber => $biblionumber, >+ itemnumber => $itemnumber, >+ found => 'W', >+ reservedate => '1900-01-01', >+ waitingdate => '1900-01-01', >+ lowestPriority => 0, >+ suspend => 0, >+ } >+)->store(); >+my $hold_2 = Koha::Hold->new( >+ { >+ priority => 1, >+ borrowernumber => $patron_2->{borrowernumber}, >+ branchcode => $library->{branchcode}, >+ biblionumber => $biblionumber, >+ itemnumber => $itemnumber, >+ reservedate => '1900-01-01', >+ lowestPriority => 0, >+ suspend => 0, >+ } >+)->store(); >+my $hold_3 = Koha::Hold->new( >+ { >+ priority => 1, >+ borrowernumber => $patron_2->{borrowernumber}, >+ branchcode => $library->{branchcode}, >+ biblionumber => $biblionumber, >+ itemnumber => $itemnumber, >+ reservedate => '1900-01-01', >+ lowestPriority => 0, >+ suspend => 0, >+ } >+)->store(); >+ >+# Test CancelExpiredReserves >+t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelay', 1 ); >+t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', 1 ); >+t::lib::Mocks::mock_preference( 'ExpireReservesOnHolidays', 1 ); >+t::lib::Mocks::mock_preference( 'ExpireReservesAutoFill', 1 ); >+t::lib::Mocks::mock_preference( 'ExpireReservesAutoFillEmail', >+ 'kyle@example.com' ); >+ >+CancelExpiredReserves(); >+ >+my @holds = Koha::Holds->search( {}, { order_by => 'priority' } ); >+$hold_2 = $holds[0]; >+$hold_3 = $holds[1]; >+ >+is( @holds, 2, 'Found 2 holds' ); >+is( $hold_2->priority, 0, 'Next hold in line now has priority of 0' ); >+is( $hold_2->found, 'W', 'Next hold in line is now set to waiting' ); >+ >+my @messages = $schema->resultset('MessageQueue') >+ ->search( { letter_code => 'HOLD_CHANGED' } ); >+is( @messages, 1, 'Found 1 message in the message queue' ); >+is( $messages[0]->to_address, 'kyle@example.com', 'Message sent to correct email address' ); >+ >+$hold_2->waitingdate('1900-01-01')->store(); >+ >+CancelExpiredReserves(); >+ >+@holds = Koha::Holds->search( {}, { order_by => 'priority' } ); >+$hold_3 = $holds[0]; >+ >+is( @holds, 1, 'Found 1 hold' ); >+is( $hold_3->priority, 0, 'Next hold in line now has priority of 0' ); >+is( $hold_3->found, 'W', 'Next hold in line is now set to waiting' ); >+ >+# Helper method to set up a Biblio. >+sub create_helper_biblio { >+ my $itemtype = shift; >+ my $bib = MARC::Record->new(); >+ my $title = 'Silence in the library'; >+ $bib->append_fields( >+ MARC::Field->new( '100', ' ', ' ', a => 'Moffat, Steven' ), >+ MARC::Field->new( '245', ' ', ' ', a => $title ), >+ MARC::Field->new( '942', ' ', ' ', c => $itemtype ), >+ ); >+ return my ( $b, $t, $bi ) = AddBiblio( $bib, '' ); >+} >-- >2.1.4
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 14364
:
39998
|
41236
|
45149
|
49699
|
49700
|
49822
|
52310
|
52311
|
52312
|
71148
|
80126
|
103297
|
105015
|
115427
|
115466
|
120494
|
120941
|
120942
|
128757
|
128758
|
128759
|
132019
|
132020
|
132021
|
133812
|
133923
|
133924
|
133925
|
133926
|
133927
|
133928
|
137927
|
137928
|
137929
|
137930
|
137931
|
137932