Bugzilla – Attachment 181056 Details for
Bug 7376
Transfer limits should be checked at check-in
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7376: Unit test
Bug-7376-Unit-test.patch (text/plain), 8.18 KB, created by
Mathieu Saby
on 2025-04-17 11:55:17 UTC
(
hide
)
Description:
Bug 7376: Unit test
Filename:
MIME Type:
Creator:
Mathieu Saby
Created:
2025-04-17 11:55:17 UTC
Size:
8.18 KB
patch
obsolete
>From 608faedc06f59b2f6329f9ea642ca9edd031eeec Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Mon, 16 Dec 2024 10:59:22 +0100 >Subject: [PATCH] Bug 7376: Unit test > >Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> >Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> >Signed-off-by: Mathieu Saby <mathsabypro@gmail.com> >--- > t/db_dependent/Circulation.t | 67 +++++++++++++++++++++++++++++------- > 1 file changed, 55 insertions(+), 12 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 4406b55a5a..983b445b45 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -19,7 +19,7 @@ use Modern::Perl; > use utf8; > > use Test::NoWarnings; >-use Test::More tests => 76; >+use Test::More tests => 77; > use Test::Exception; > use Test::MockModule; > use Test::Deep qw( cmp_deeply ); >@@ -1182,7 +1182,7 @@ subtest "CanBookBeRenewed tests" => sub { > ); > > my $ten_days_before = dt_from_string->add( days => -10 ); >- my $ten_days_ahead = dt_from_string->add( days => 10 ); >+ my $ten_days_ahead = dt_from_string->add( days => 10 ); > my $issue = AddIssue( > $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, > undef, { auto_renew => 1 } >@@ -1332,7 +1332,7 @@ subtest "CanBookBeRenewed tests" => sub { > ); > > my $ten_days_before = dt_from_string->add( days => -10 ); >- my $ten_days_ahead = dt_from_string->add( days => 10 ); >+ my $ten_days_ahead = dt_from_string->add( days => 10 ); > my $issue = AddIssue( > $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, > undef, { auto_renew => 1 } >@@ -1442,7 +1442,7 @@ subtest "CanBookBeRenewed tests" => sub { > ); > > my $ten_days_before = dt_from_string->add( days => -10 ); >- my $ten_days_ahead = dt_from_string->add( days => 10 ); >+ my $ten_days_ahead = dt_from_string->add( days => 10 ); > > # Patron is expired and BlockExpiredPatronOpacActions='' > # => auto renew is allowed >@@ -1494,7 +1494,7 @@ subtest "CanBookBeRenewed tests" => sub { > ); > > my $ten_days_before = dt_from_string->add( days => -10 ); >- my $ten_days_ahead = dt_from_string->add( days => 10 ); >+ my $ten_days_ahead = dt_from_string->add( days => 10 ); > my $issue = AddIssue( > $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, > undef, { auto_renew => 1 } >@@ -1529,7 +1529,7 @@ subtest "CanBookBeRenewed tests" => sub { > } > } > ); >- $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrower_obj,, $issue ); >+ $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrower_obj, $issue ); > is( > $latest_auto_renew_date->truncate( to => 'minute' ), > $five_days_before->truncate( to => 'minute' ), >@@ -1615,7 +1615,7 @@ subtest "CanBookBeRenewed tests" => sub { > ); > > my $ten_days_before = dt_from_string->add( days => -10 ); >- my $ten_days_ahead = dt_from_string->add( days => 10 ); >+ my $ten_days_ahead = dt_from_string->add( days => 10 ); > my $issue = AddIssue( > $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, > undef, { auto_renew => 1 } >@@ -1965,7 +1965,7 @@ subtest "GetUpcomingDueIssues" => sub { > my $a_borrower = Koha::Patrons->find($a_borrower_borrowernumber); > > my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); >- my $two_days_ahead = DateTime->today( time_zone => C4::Context->tz() )->add( days => 2 ); >+ my $two_days_ahead = DateTime->today( time_zone => C4::Context->tz() )->add( days => 2 ); > my $today = DateTime->today( time_zone => C4::Context->tz() ); > > my $issue = AddIssue( $a_borrower, $item_1->barcode, $yesterday ); >@@ -2842,6 +2842,49 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { > ); > }; > >+subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub { >+ plan tests => 6; >+ >+ my $homebranch = $builder->build( { source => 'Branch' } ); >+ my $otherbranch = $builder->build( { source => 'Branch' } ); >+ my $patron = >+ $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); >+ >+ my $item = $builder->build_sample_item( >+ { >+ homebranch => $homebranch->{branchcode}, >+ holdingbranch => $homebranch->{branchcode}, >+ } >+ ); >+ >+ t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); >+ set_userenv($homebranch); >+ my $issue = AddIssue( $patron, $item->barcode ); >+ my ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $otherbranch ); >+ is( 1, $allowed, 'with AllowReturnToBranch = anywhere and no limits return to other is allowed' ); >+ is( undef, $message, 'without limits provides no message' ); >+ >+ t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '1' ); >+ t::lib::Mocks::mock_preference( 'BranchTransferLimitsType', 'itemtype' ); >+ >+ # set limit >+ my $limit = Koha::Item::Transfer::Limit->new( >+ { >+ toBranch => $otherbranch->{branchcode}, >+ fromBranch => $item->homebranch, >+ itemtype => $item->effective_itemtype, >+ } >+ )->store(); >+ >+ ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $otherbranch ); >+ is( 0, $allowed, 'With transfer limits cannot return to otherbranch' ); >+ is( $homebranch->{branchcode}, $message, 'With transfer limits asks return to homebranch' ); >+ >+ ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $homebranch ); >+ is( 1, $allowed, 'With transfer limits can return to homebranch' ); >+ is( undef, $message, 'With transfer limits and homebranch provides no message' ); >+}; >+ > subtest 'Statistic patrons "X"' => sub { > plan tests => 15; > >@@ -3877,7 +3920,7 @@ subtest 'AddReturn | is_overdue' => sub { > is( $line->status, 'RETURNED', "Overdue fine is fixed" ); > $line = $lines->next; > is( $line->amount + 0, -2, "Original payment amount remains as 2" ); >- is( $line->amountoutstanding + 0, 0, "Original payment remains applied" ); >+ is( $line->amountoutstanding + 0, 0, "Original payment remains applied" ); > $line = $lines->next; > is( $line->amount + 0, -1, "Refund amount correctly set to 1" ); > is( $line->amountoutstanding + 0, -1, "Refund amount outstanding unspent" ); >@@ -4792,7 +4835,7 @@ subtest '_FixOverduesOnReturn' => sub { > my $credit = $offset->credit; > is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" ); > is( $credit->amount + 0, -99, "Credit amount is set correctly" ); >- is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" ); >+ is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" ); > > # Bug 25417 - Only forgive fines where there is an amount outstanding to forgive > $accountline->set( >@@ -7325,7 +7368,7 @@ subtest 'NoRefundOnLostFinesPaidAge' => sub { > { > borrowernumber => $patron->id, > date => '1970-01-01 14:00:01', >- amountoutstanding => 0, >+ amountoutstanding => 0, > amount => -5, > interface => 'commandline', > credit_type_code => 'PAYMENT' >@@ -7381,7 +7424,7 @@ subtest 'NoRefundOnLostFinesPaidAge' => sub { > borrowernumber => $patron2->id, > date => '1970-01-01 14:00:01', > amount => -5, >- amountoutstanding => 0, >+ amountoutstanding => 0, > interface => 'commandline', > credit_type_code => 'PAYMENT' > } >-- >2.39.5
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 7376
:
6954
|
21715
|
21805
|
22016
|
22017
|
22323
|
22357
|
22696
|
23168
|
76559
|
76866
|
76876
|
92740
|
92774
|
93190
|
93191
|
93192
|
93193
|
93194
|
93195
|
93196
|
107077
|
107078
|
107079
|
115369
|
115370
|
116493
|
116494
|
116927
|
116928
|
116937
|
116938
|
120897
|
120898
|
120899
|
120900
|
120901
|
120902
|
120903
|
144435
|
144436
|
144437
|
144438
|
144439
|
144440
|
144441
|
175690
|
175691
|
175692
|
175693
|
175694
|
175695
|
175696
|
175697
|
180069
|
180070
|
180071
|
180072
|
180073
|
180074
|
180075
|
180076
|
180590
|
180591
|
180592
|
180593
|
180594
|
180595
|
180596
|
180597
|
181055
|
181056
|
181057
|
181058
|
181059
|
181060
|
181061
|
181062
|
181064
|
181065
|
181066
|
181067
|
181068
|
181069
|
181070
|
181071