Bugzilla – Attachment 131440 Details for
Bug 30114
Koha offline circulation will always cancel the next hold when issuing item to a patron
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30114: Add Unit Tests
Bug-30114-Add-Unit-Tests.patch (text/plain), 4.94 KB, created by
Kyle M Hall (khall)
on 2022-03-07 14:49:32 UTC
(
hide
)
Description:
Bug 30114: Add Unit Tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2022-03-07 14:49:32 UTC
Size:
4.94 KB
patch
obsolete
>From 351687b9a9803bfa0a13f16813887374d34be419 Mon Sep 17 00:00:00 2001 >From: Kyle Hall <kyle@bywatersolutions.com> >Date: Mon, 7 Mar 2022 09:07:14 -0500 >Subject: [PATCH] Bug 30114: Add Unit Tests > >--- > .../Circulation/OfflineCirculation.t | 140 ++++++++++++++++++ > 1 file changed, 140 insertions(+) > create mode 100755 t/db_dependent/Circulation/OfflineCirculation.t > >diff --git a/t/db_dependent/Circulation/OfflineCirculation.t b/t/db_dependent/Circulation/OfflineCirculation.t >new file mode 100755 >index 0000000000..b0006395be >--- /dev/null >+++ b/t/db_dependent/Circulation/OfflineCirculation.t >@@ -0,0 +1,140 @@ >+#!/usr/bin/perl >+ >+# 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 => 1; >+use Test::MockModule; >+use Test::Warn; >+ >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ >+use C4::Biblio qw( AddBiblio ); >+use C4::Circulation qw( AddOfflineOperation ProcessOfflineOperation GetOfflineOperation ); >+use C4::Context; >+use C4::Reserves qw( AddReserve ); >+use Koha::DateUtils qw( dt_from_string ); >+ >+use MARC::Record; >+ >+#Â Mock userenv, used by AddIssue >+my $branch; >+my $manager_id; >+my $context = Test::MockModule->new('C4::Context'); >+$context->mock( >+ 'userenv', >+ sub { >+ return { >+ branch => $branch, >+ number => $manager_id, >+ firstname => "Adam", >+ surname => "Smaith" >+ }; >+ } >+); >+ >+my $schema = Koha::Database->schema; >+$schema->storage->txn_begin; >+ >+my $dbh = C4::Context->dbh; >+ >+my $builder = t::lib::TestBuilder->new(); >+ >+subtest "Bug 30114 - Koha offline circulation will always cancel the next hold when issuing item to a patron" => sub { >+ >+ plan tests => 3; >+ >+ $dbh->do("DELETE FROM pending_offline_operations"); >+ >+ # Set item-level item types >+ t::lib::Mocks::mock_preference( "item-level_itypes", 1 ); >+ >+ #Â Create a branch >+ $branch = $builder->build({ source => 'Branch' })->{ branchcode }; >+ #Â Create a borrower >+ my $borrower1 = $builder->build({ >+ source => 'Borrower', >+ value => { branchcode => $branch } >+ }); >+ >+ my $borrower2 = $builder->build({ >+ source => 'Borrower', >+ value => { branchcode => $branch } >+ }); >+ >+ my $borrower3 = $builder->build({ >+ source => 'Borrower', >+ value => { branchcode => $branch } >+ }); >+ >+ #Â Look for the defined MARC field for biblio-level itemtype >+ my $rs = $schema->resultset('MarcSubfieldStructure')->search({ >+ frameworkcode => '', >+ kohafield => 'biblioitems.itemtype' >+ }); >+ my $tagfield = $rs->first->tagfield; >+ my $tagsubfield = $rs->first->tagsubfield; >+ >+ # Create a biblio record with biblio-level itemtype >+ my $record = MARC::Record->new(); >+ my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' ); >+ my $itype = $builder->build({ source => 'Itemtype' }); >+ my $item = $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ library => $branch, >+ itype => $itype->{itemtype}, >+ } >+ ); >+ >+ AddReserve( >+ { >+ branchcode => $branch, >+ borrowernumber => $borrower1->{borrowernumber}, >+ biblionumber => $biblionumber, >+ priority => 1, >+ itemnumber => $item->id, >+ } >+ ); >+ >+ AddReserve( >+ { >+ branchcode => $branch, >+ borrowernumber => $borrower2->{borrowernumber}, >+ biblionumber => $biblionumber, >+ priority => 2, >+ itemnumber => $item->id, >+ } >+ ); >+ >+ my $now = dt_from_string->truncate( to => 'minute' ); >+ AddOfflineOperation( $borrower3->{borrowernumber}, $borrower3->{branchcode}, $now, 'issue', $item->barcode, $borrower3->{cardnumber} ); >+ >+ my $offline_rs = Koha::Database->new()->schema()->resultset('PendingOfflineOperation')->search(); >+ is( $offline_rs->count, 1, "Found one pending offline operation" ); >+ >+ is( Koha::Holds->search({ biblionumber => $biblionumber })->count, 2, "Found two holds for the record" ); >+ >+ my $op = GetOfflineOperation( $offline_rs->next->id ); >+ >+ my $ret = ProcessOfflineOperation( $op ); >+ >+ is( Koha::Holds->search({ biblionumber => $biblionumber })->count, 2, "Still found two holds for the record" ); >+}; >+ >+$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 30114
:
130631
|
130669
|
131033
|
131440
|
131441
|
132190
|
132191